What is docker compose ?
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
Benefits of Docker Compose
- Single host deployment – This means you can run everything on a single piece of hardware
- Quick and easy configuration – Due to YAML scripts
- High productivity – Docker Compose reduces the time it takes to perform tasks
- Security – All the containers are isolated from each other, reducing the threat landscape
Just quick post with example about docker-compose file to show you how much powerful this instead of running docker compose
- create file called docker-compose.yml
version: '3' services: ghost: image: ghost:1-alpine container_name: ghost-blog restart: always ports: - 80:2368 environment: database__client: mysql database__connection__host: mysql database__connection__user: root database__connection__password: P4sSw0rd0! database__connection__database: ghost volumes: - ghost-volume:/var/lib/ghost depends_on: - mysql mysql: image: mysql:5.7 container_name: ghost-db restart: always environment: MYSQL_ROOT_PASSWORD: P4sSw0rd0! volumes: - mysql-volume:/var/lib/mysql volumes: ghost-volume: mysql-volume:
docker-compose up -d