0
0
Dockerdevops~10 mins

Sharing volumes between containers in Docker - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Docker volume named 'data_vol'.

Docker
docker volume [1] data_vol
Drag options to blanks, or click blank then click option'
Abuild
Brun
Cstart
Dcreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'docker volume run' instead of 'create'.
Trying to start or build a volume.
2fill in blank
medium

Complete the code to run a container named 'app1' and mount the volume 'data_vol' to '/app/data'.

Docker
docker run -d --name app1 -v [1]:/app/data alpine sleep 1000
Drag options to blanks, or click blank then click option'
Adata_vol
B/data
Capp1_vol
D/app/data
Attempts:
3 left
💡 Hint
Common Mistakes
Using container path instead of volume name before colon.
Using wrong volume name.
3fill in blank
hard

Fix the error in the command to run a second container 'app2' sharing the same volume 'data_vol' at '/app/data'.

Docker
docker run -d --name app2 -v [1]:/app/data alpine sleep 1000
Drag options to blanks, or click blank then click option'
A/app/data
Bdata_vol
Capp2_vol
Ddata_vol:/app/data
Attempts:
3 left
💡 Hint
Common Mistakes
Using full volume and path together as one option.
Using container path instead of volume name.
4fill in blank
hard

Fill both blanks to create a Docker Compose service 'app1' that uses the volume 'data_vol' mounted at '/app/data'.

Docker
version: '3.8'\nservices:\n  app1:\n    image: alpine\n    command: sleep 1000\n    volumes:\n      - [1]:[2]\nvolumes:\n  data_vol: {}
Drag options to blanks, or click blank then click option'
Adata_vol
B/app/data
C/data
Dapp1_data
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping volume name and container path.
Using wrong volume or path names.
5fill in blank
hard

Fill all three blanks to define a Docker Compose file with two services 'app1' and 'app2' sharing the volume 'shared_vol' mounted at '/data' in both containers.

Docker
version: '3.8'\nservices:\n  app1:\n    image: alpine\n    command: sleep 1000\n    volumes:\n      - [1]:[2]\n  app2:\n    image: alpine\n    command: sleep 1000\n    volumes:\n      - [3]:[2]\nvolumes:\n  shared_vol: {}
Drag options to blanks, or click blank then click option'
Ashared_vol
B/data
D/app/data
Attempts:
3 left
💡 Hint
Common Mistakes
Using different volume names for each service.
Using different mount paths.