0
0
Dockerdevops~10 mins

Running a container with docker run - Interactive Code Practice

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

Complete the command to run a container from the nginx image.

Docker
docker run [1] nginx
Drag options to blanks, or click blank then click option'
A--name
B-p
C-d
D-v
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-p' which is for port mapping, not for running in background.
Using '--name' which names the container but does not run it detached.
2fill in blank
medium

Complete the command to map port 8080 on the host to port 80 in the container.

Docker
docker run -d [1] 8080:80 nginx
Drag options to blanks, or click blank then click option'
A-p
B--name
C--rm
D-v
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-v' which is for volume mapping, not ports.
Using '--rm' which removes the container after exit.
3fill in blank
hard

Fix the error in the command to name the container 'webserver'.

Docker
docker run -d [1] webserver nginx
Drag options to blanks, or click blank then click option'
A--name
B-p
C-v
D--rm
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-p' which is for port mapping.
Using '-v' which is for volume mapping.
4fill in blank
hard

Fill both blanks to run a container named 'db' and remove it after it stops.

Docker
docker run [1] [2] db postgres
Drag options to blanks, or click blank then click option'
A--rm
B-d
C--name
D-p
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-p' which is for port mapping instead of naming.
Using '-d' which runs detached but does not remove container.
5fill in blank
hard

Fill all three blanks to run a detached container named 'app', and mount host folder '/data' to '/app/data' in the container.

Docker
docker run [1] [2] app [3] /data:/app/data nginx
Drag options to blanks, or click blank then click option'
A-d
B--name
C-p
D-v
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-p' for volume mounting instead of '-v'.
Forgetting to run detached with '-d'.