About
Docker Compose is a powerful tool that enables you to launch multiple Docker images in a coordinated fashion.
Compose is a tool for defining and running multi-container Docker applications.
Compose uses a project name as identifier to isolate environments from each other.
Articles Related
Steps
Using Compose is basically a three-step process.
- Define your app’s environment with a Dockerfile so it can be reproduced anywhere.
- Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
- Lastly, run docker-compose up and Compose will start and run your entire app.
Management
Command
Compose has commands for managing the whole lifecycle of your application:
- Start, stop and rebuild services
- View the status of running services
- Stream the log output of running services
- Run a one-off command on a service
List
ps (listing and status)
docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------------------------------------------------------
quickstart_kafka_1 /etc/confluent/docker/run Up 0.0.0.0:29092->29092/tcp, 0.0.0.0:9092->9092/tcp
quickstart_ksql-cli_1 perl -e while(1){ sleep 99 ... Up
quickstart_ksql-datagen-pageviews_1 bash -c echo Waiting for K ... Exit 1
quickstart_ksql-datagen-users_1 bash -c echo Waiting for K ... Exit 1
quickstart_schema-registry_1 /etc/confluent/docker/run Up 0.0.0.0:8081->8081/tcp
quickstart_zookeeper_1 /etc/confluent/docker/run Up 2181/tcp, 2888/tcp, 0.0.0.0:32181->32181/tcp, 3888/tcp
image
docker-compose images
top (Process Info and Command )
docker-compose top
See the process information and command
up
docker-compose up -d
# or
docker-compose up -d -f docker-compose.yml
# or
docker stack up -c docker-compose.yml Stack
where:
- -d is called the Detached mode: Run containers in the background, print new container names.
Configuration can be overwritten by another Docker - docker-compose.yml.
Example:
- from Kafka
docker-compose -f docker-compose.yml -f rpm-overides.yml up
- build before up
docker-compose up -d --build
down
docker-compose down
Stopping kafkasinglenode_kafka_1 ... done
Stopping kafkasinglenode_zookeeper_1 ... done
Removing kafkasinglenode_kafka_1 ... done
Removing kafkasinglenode_zookeeper_1 ... done
update
- Change the configuration file and make a configuration change to a service
- Update it
docker-compose up
The old container will be removed and the new one will created with the same name.
Configuration
- Environment variable: https://docs.docker.com/compose/reference/envvars/
- Services Configuration: docker-compose.yml