1. Docker: Volume Mounting
The task is to complete a file stub
"/home/ubuntu/835979-dockervolume-mounting/script.sh" with one or more
steps that do the following:
• Runs a new Docker container "my-container-rw" from the "busybox" image
(latest tag) in interactive background mode, without pseudoTTY
allocation.
• Runs a new Docker container "my-container-ro" from the "busybox" image
(latest tag) in interactive background mode, without pseudoTTY
allocation.
• Mounts an existing volume"/home/ubuntu/835979-docker-volumemounting"
at "/mnt" of the "my-container-rw"container in "readwrite" mode.
• Mounts an existing volume "/home/ubuntu/835979-docker-volumemounting"
at "/mnt" of the "my-container-ro" container in "readonly" mode.
Note
• The completed solution will be evaluated in a new, clean
environment. Be sure everything is in the "/home/ubuntu/835979docker-volume-mounting" folder.
• All the tasks should be done within a simple "sudo solve" execution
Invoked from the question directory.
• Docker is already installed.
• You have sudo access.
Grading
• The execution result of "docker exec my-container-ro rm /mnt/my
file.txt" outputs a "read-only file system" error.
• The execution result of "docker exec my-container-rw rm /mnt/my.
file.txt" removes the file from both the host and all the containers.
Solution:
Write the below command in script.sh
#!/usr/bin/env bash
docker run -di -v /home/ubuntu/835979-docker-volume-mounting:/mnt --name my-container-rw busybox: latest
docker run -di -v /home/ubuntu/835979-docker-volume-mounting:/mnt:ro --name my-container-ro busybox:latest
docker exec my-container-ro rm /mnt/my-file.txt
docker exec my-container-rw rm /mnt/my-file.txt
Then run sudo solve
I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More:
Click Here
0 comments:
Post a Comment