# Connecting Docker Containers to Docker Networks To connect an existing container to a network use `docker network connect <NETWORK NAME> <CONTAINER NAME>` You can optionally configure a fix IP with the `--ip` option. ## Specifying Networks When Creating a Container Using the CLI You can specify networks a container should be connected to when creating the container by using the following `docker run` options: ![[Docker#^3fhrkf]] ## Connecting Docker Compose Services to Networks You specify networks services should be connected to using the `networks:` configuration section of a particular service (note that this is not the same as the top-level `networks:` configuration section). ![[Docker Compose#^kjfdlo]] To map service ports you use the `ports:` configuration section of a particular service. ![[Docker Compose#^l4lb4o]]