I’m trying to practice docker swarm. Our goal is to deploy the project with docker swarm, and we can use it as production by docker warm. Next goals, we will try to demo scale with 3 Linux hosts by docker swarm
So we understand how we scale our project big with docker swarm.
docker swarm init
docker network create --driver overlay NETWORK_NAME
Note: sometimes your project cannot run because of the network, you need to update networks of all services in the docker-compose file to → overlay Also, I got an error when I deploy the docker-compose file with the bridge network config, it creates a bridge network for the swarm env, then when I change the config in docker-compose to overlay network, the error is not gone. You need to remove that bridge network before deploying by Swarm again
networks:
node-network:
driver: overlay
docker stack deploy -c docker-compose.yml STACK_NAME
Manage your services
docker service ls
docker ps
docker inspect CONTAINER_ID(or CONTAINER_NAME)
docker logs -f CONTAINER_ID(or CONTAINER_NAME)