Docker ~ Use the existing network in yml and the existing network in dockeryml
Back to directory
When deploying a highly available cluster using docker swarm, we may need to configure some services in the yml file, and these services may need to use some public databases, these databases may already run in a container, and these containers have their own network and docker inspect container ID to view the network used by the container, use docker network ls to view the network currently created by docker.
In yml version 3, let's take a look at how to use the existing network
Version: "3" services: nginx: image: nginx networks:-core-infranetworks: core-infra: external: true
It is also possible to create a mongodb instance using an existing network.
Version: "3" services: mongodb: image: mongo: latest ports:-"27017: 27017" networks:-test-networknetworks: test-network: external: true
If you do not add the external parameter, it will create a new network, and the network prefix will be a service name, which is clear!
Article reference: http://www.dockerinfo.net/4245.html
Thank you for reading this article!
Back to directory