Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The '-d' option runs the container in detached mode, so it runs in the background.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-v' which is for volume mapping, not ports.
Using '--rm' which removes the container after exit.
✗ Incorrect
The '-p' option maps ports from host to container.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-p' which is for port mapping.
Using '-v' which is for volume mapping.
✗ Incorrect
The '--name' option assigns a name to the container.
4fill in blank
hardFill 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'
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.
✗ Incorrect
Use '--rm' to remove the container after it stops and '--name' to name it.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-p' for volume mounting instead of '-v'.
Forgetting to run detached with '-d'.
✗ Incorrect
Use '-d' for detached mode, '--name' to name the container, and '-v' to mount volumes.