164k views
1 vote
What is the docker command to add a network to a running service?

a) docker network attach [network ID] [service ID]
b) docker service connect [network ID] [service ID]
c) docker service network add [service ID] [network ID]
d) docker network connect [network ID] [container ID]

User Libjack
by
7.2k points

1 Answer

3 votes

Final answer:

The correct Docker command to add a network to a running service is 'docker network connect [network ID] [container ID]'. This command allows you to connect a running Docker container to a specific network by providing the network ID and the container ID.

Step-by-step explanation:

The correct Docker command to add a network to a running service is d) docker network connect [network ID] [container ID].

This command allows you to connect a running Docker container to a specific network by providing the network ID and the container ID.

For example, if you have a network with ID 'my-net' and a container with ID 'my-container', the command would be:

docker network connect my-net my-container

User Gil Nave
by
8.1k points