nerdexam
Docker

DCA · Question #115

You want to create a container that is reachable from its host's network. Does this action accomplish this? Solution: Use either EXPOSE or --publish to access the containers on the bridge network

The correct answer is A. Yes. Using --publish (or -p) explicitly maps container ports to host ports, making the container reachable from the host's network, while EXPOSE merely documents the ports.

Submitted by emma.c· Apr 18, 2026Networking

Question

You want to create a container that is reachable from its host's network. Does this action accomplish this? Solution: Use either EXPOSE or --publish to access the containers on the bridge network

Options

  • AYes
  • BNo

How the community answered

(40 responses)
  • A
    85% (34)
  • B
    15% (6)

Why each option

Using `--publish` (or `-p`) explicitly maps container ports to host ports, making the container reachable from the host's network, while `EXPOSE` merely documents the ports.

AYesCorrect

The `--publish` (or short form `-p`) option maps a container port to a host port, making the container's service accessible from the host's network interfaces. While `EXPOSE` only declares the port, `--publish` actually opens it on the host, fulfilling the requirement for host reachability.

BNo

The `--publish` option specifically enables host-to-container port mapping, making the container accessible from the host network.

Concept tested: Docker container port publishing

Source: https://docs.docker.com/engine/reference/run/#publish-or-expose-port-s

Topics

#Port mapping#Container networking#EXPOSE command#Publish ports

Community Discussion

No community discussion yet for this question.

Full DCA Practice