Skip to main content
Code and think

Docker Network

When you work with multiple docker containers that are not in the same compose file, the issue is that each is in a different network. However, there is a useful docker command to add an existing container to an existing network:

docker network connect [OPTIONS] NETWORK CONTAINER

An example would be to add a container named mycontainer to the network mynetwork:

docker network connect mynetwork mycontainer

Reference

Beside that there are two more useful commands in docker network:

First one displays all network controllers in Docker:

docker network ls

Reference

And the second one displays details of a Docker network:

docker network inspect mynetwork

Reference