Docker Swarm Contd..
- We have initialize the swarm cluster and created two services
- nginx
docker service create --replicas 2 --publish mode=host,target=80,published=8080 nginx
- jenkins
docker service create --replicas 2 --publish mode=host,target=8080,published=8081 jenkins/jenkins
- nginx
- To access them we have used 8080 port of any node in cluster
- To access jenkins we have used 8081 port of any node in cluster
Docker-Compose
- Docker compose lets run multiple containers in a Docker and also lets define the necessary volumes and networks
- Hello-world docker compose. Create a file called as docker-compose.yaml
services:
app:
image: httpd
ports:
- "8080:80"
db:
image: mysql
- now execute docker-compose up -d
Exercise:
- Try running the flask application and database in a same bridge network Refer Here