305-300 · Question #88
After creating a new Docker network using the following command: docker network create --driver bridge isolated_nw Which parameter must be added to docker create in order to attach a container to…
The correct answer is D. --network=isolated_nw. To attach a container to a network when creating it, the --network flag must be used with the name of the network as the argument. The --network flag specifies the network mode for the container. By default, the network mode is bridge, which means the container is connected to…
Question
Options
- A--eth0=isolated_nw
- B--alias=isolated_nw
- C--ethernet=isolated_nw
- D--network=isolated_nw
- E--attach=isolated_nw
How the community answered
(31 responses)- A10% (3)
- B3% (1)
- D84% (26)
- E3% (1)
Explanation
To attach a container to a network when creating it, the --network flag must be used with the name of the network as the argument. The --network flag specifies the network mode for the container. By default, the network mode is bridge, which means the container is connected to the default bridge network. However, if a custom network is created, such as isolated_nw in this case, the container must be explicitly attached to it using the --network flag. For example, to create a container named web1 and attach it to the isolated_nw network, the command would be: docker create --name web1 --network isolated_nw nginx
Topics
Community Discussion
No community discussion yet for this question.