0
0
Dockerdevops~10 mins

Exposing ports to host in Docker - Interactive Code Practice

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

Complete the command to expose port 80 of the container to port 8080 on the host.

Docker
docker run -p [1]:80 nginx
Drag options to blanks, or click blank then click option'
A3000
B8080
C443
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using the container port as the host port.
Swapping the ports in the mapping.
2fill in blank
medium

Complete the command to expose port 5432 of the container to the same port on the host.

Docker
docker run -p [1]:5432 postgres
Drag options to blanks, or click blank then click option'
A3306
B8080
C5432
D5000
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different host port without reason.
Confusing container port with host port.
3fill in blank
hard

Fix the error in the command to expose port 5000 of the container to port 5000 on the host.

Docker
docker run -p 5000:[1] myapp
Drag options to blanks, or click blank then click option'
A5000
B443
C80
D8080
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping host and container ports.
Using a default port not matching the app.
4fill in blank
hard

Fill both blanks to expose port 3000 of the container to port 4000 on the host and run the container in detached mode.

Docker
docker run [1] -p [2]:3000 myapp
Drag options to blanks, or click blank then click option'
A-d
B-it
C4000
D-rm
Attempts:
3 left
💡 Hint
Common Mistakes
Using interactive mode instead of detached.
Swapping host and container ports.
5fill in blank
hard

Fill all three blanks to expose port 22 of the container to port 2222 on the host, name the container 'ssh-server', and run it in detached mode.

Docker
docker run [1] --name [2] -p [3]:22 sshd
Drag options to blanks, or click blank then click option'
A-d
Bssh-server
C2222
D-it
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to name the container.
Using wrong port mapping order.
Using interactive mode instead of detached.