Using Docker Compose

Using Docker Compose
Using Docker Compose 1
Using Docker Compose 2

docker-compose depends on the file called docker-compose.yml,the settings and clusters depends on this file

the format of the file

  property: value
    - or options
  • so here we will see one example we will connect two containers node.js application to Redis container
  • we should name to the container in the below format like in the below example the name of the container is web
  build: .
  • to link the two containers we need to specify link property, in this example we will link to Redis source container
    - redis
  • now the same format is used to setup ports for containers
    - "3000"
    - "8000"
  • for defining the second container, use below format
  image: redis:alpine
    - /var/redis/data:/data
  • after creating docker-compose.yml file, you can launch the container with the up command
for single container
up <name>

docker-compose up -d

-d states to run containers in the background

  • to see details of launched containers, you can use below command
docker-compose ps
  • to see log details
docker-compose logs
  • to stop all the containers
docker-compose stop
  • to remove all the containers
docker-compose rm

Default image
Vishal Devxo
Vishal is a DevOps engineer and a Backend developer, he spends all his time for creating good tutorials with better visuals and blogging, developed some projects based on Python-Django, some hacking modules and scripts in python
Leave a Reply