Docker - docker-compose


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.


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.



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


ps (listing and status)
docker-compose ps
               Name                              Command               State                            Ports
quickstart_kafka_1                    /etc/confluent/docker/run        Up>29092/tcp,>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>8081/tcp
quickstart_zookeeper_1                /etc/confluent/docker/run        Up       2181/tcp, 2888/tcp,>32181/tcp, 3888/tcp
docker-compose images
top (Process Info and Command )
docker-compose top

See the process information and command


docker-compose up -d
# or
docker-compose up -d -f docker-compose.yml
# or
docker stack up -c docker-compose.yml Stack


  • -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.


docker-compose -f docker-compose.yml -f rpm-overides.yml up
  • build before up
 docker-compose up -d --build


docker-compose down
Stopping kafkasinglenode_kafka_1     ... done
Stopping kafkasinglenode_zookeeper_1 ... done
Removing kafkasinglenode_kafka_1     ... done
Removing kafkasinglenode_zookeeper_1 ... done


docker-compose up

The old container will be removed and the new one will created with the same name.


Documentation / Reference

Powered by ComboStrap