0
0
Dockerdevops~10 mins

Port mapping in Compose in Docker - Interactive Code Practice

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

Complete the code to expose port 80 on the container to port 8080 on the host.

Docker
ports:
  - "[1]:80"
Drag options to blanks, or click blank then click option'
A443
B80
C8080
D3000
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the host and container ports.
Using the container port alone without mapping.
2fill in blank
medium

Complete the code to map port 5432 inside the container to port 15432 on the host.

Docker
ports:
  - "[1]:5432"
Drag options to blanks, or click blank then click option'
A5432
B15432
C3306
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using the container port as the host port.
Forgetting the colon separator.
3fill in blank
hard

Fix the error in the port mapping to correctly expose port 5000 on the container to port 5000 on the host.

Docker
ports:
  - "[1]5000"
Drag options to blanks, or click blank then click option'
A5000:
B5000
C5000-
D:5000
Attempts:
3 left
💡 Hint
Common Mistakes
Using a dash '-' instead of a colon ':'.
Omitting the host port.
4fill in blank
hard

Fill both blanks to map port 8080 on the host to port 80 on the container and port 8443 on the host to port 443 on the container.

Docker
ports:
  - "[1]:80"
  - "[2]:443"
Drag options to blanks, or click blank then click option'
A8080
B80
C8443
D443
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping host and container ports.
Using container ports on the left side.
5fill in blank
hard

Fill all three blanks to create a port mapping in Compose that exposes port 3000 on the host to port 3000 on the container, and port 5000 on the host to port 5000 on the container, and port 8000 on the host to port 80 on the container.

Docker
ports:
  - "[1]:3000"
  - "[2]:5000"
  - "[3]:80"
Drag options to blanks, or click blank then click option'
A3000
B5000
C8000
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up host and container ports.
Using container ports on the left side.