nerdexam
Docker

DCA · Question #15

You have created a Docker bridge network on a host with three containers attached, how do you make this containers accessible outside of the host?

The correct answer is B. Use either EXPOSE or --publish to access the containers on the bridge network. To make containers on a Docker bridge network accessible from outside the host, you must map container ports to host ports using the --publish (or -p) flag.

Submitted by rania.sa· Apr 18, 2026Networking

Question

You have created a Docker bridge network on a host with three containers attached, how do you make this containers accessible outside of the host?

Options

  • AUse network attach to access the containers on the bridge network
  • BUse either EXPOSE or --publish to access the containers on the bridge network
  • CUse network connect to access the containers on the bridge network
  • DUse --link to access the containers on the bridge network Correct

How the community answered

(15 responses)
  • A
    7% (1)
  • B
    87% (13)
  • C
    7% (1)

Why each option

To make containers on a Docker bridge network accessible from outside the host, you must map container ports to host ports using the `--publish` (or `-p`) flag.

AUse network attach to access the containers on the bridge network

`docker network attach` is used to attach an already running container to an existing network, not to make it accessible from outside the host.

BUse either EXPOSE or --publish to access the containers on the bridge networkCorrect

The `--publish` (or `-p`) flag explicitly maps a container's port to a host's port, making the service accessible on the host's IP address. While `EXPOSE` only documents ports, it works with `-P` to publish them to random host ports, making both relevant for external access.

CUse network connect to access the containers on the bridge network

`docker network connect` is used to connect a container to a network, but does not provide external host access.

DUse --link to access the containers on the bridge network Correct

The `--link` flag is a legacy feature for inter-container communication on the same Docker host and does not facilitate external access from outside the host.

Concept tested: Exposing Docker container ports

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

Topics

#Port Mapping#External Access#Docker Bridge Networks#--publish

Community Discussion

No community discussion yet for this question.

Full DCA Practice