0
0
Dockerdevops~10 mins

Mounting read-only volumes in Docker - Interactive Code Practice

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

Complete the Docker run command to mount a volume as read-only.

Docker
docker run -v /host/data:/container/data[1] alpine ls /container/data
Drag options to blanks, or click blank then click option'
A:r
B:rw
C:ro
D:read
Attempts:
3 left
💡 Hint
Common Mistakes
Using ':rw' which mounts the volume as read-write.
Using ':r' or ':read' which are invalid suffixes.
2fill in blank
medium

Complete the Docker Compose volume definition to mount a host directory as read-only.

Docker
volumes:
  data:
    driver: local
    driver_opts:
      device: /host/data
      o: [1]
      type: none
Drag options to blanks, or click blank then click option'
Aro
Brw
Cread
Dr
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'rw' which allows writing.
Using 'read' or 'r' which are not valid mount options.
3fill in blank
hard

Fix the error in the Docker run command to correctly mount the volume as read-only.

Docker
docker run -v /host/data:/container/data[1] alpine ls /container/data
Drag options to blanks, or click blank then click option'
A:ro
B:read-only
C:readonly
D:rw
Attempts:
3 left
💡 Hint
Common Mistakes
Using ':readonly' or ':read-only' which are invalid.
Using ':rw' which mounts as read-write.
4fill in blank
hard

Complete the code to mount a host directory as read-only and run a container that lists its contents.

Docker
docker run -v /host/data:/container/data[1] alpine ls /container/data
Drag options to blanks, or click blank then click option'
A:
B:ro
C:rw
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Missing ':' between host and container paths.
Using ':rw' instead of ':ro' for read-only.
5fill in blank
hard

Fill both blanks to create a Docker Compose service that mounts a volume read-only and runs a command.

Docker
services:
  app:
    image: alpine
    volumes:
      - /host/data:/container/data[1]
    command: ls [2] /container/data
Drag options to blanks, or click blank then click option'
A:
B:ro
D-l
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting ':' between paths.
Not using ':ro' for read-only volume.
Forgetting '-l' for detailed listing.