Installing Docker Compose on CentOS 7

How to install Docker Compose and run a multi-container application on CentOS 7.

Docker is software for automating the deployment and management of applications using container-level virtualization. It lets you package an application with all its dependencies into an isolated container that can be moved to any Linux system with cgroups support. Available on VPS and dedicated servers.

Docker Compose is a tool for defining and running multi-container applications. Services are configured in a YAML file, letting you spin up the entire environment with a single command.

Docker

Before installing Docker Compose, make sure Docker is already installed — see Installing Docker on CentOS 7.

Installation

Check the latest release and update the version number in the command if needed:

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Set the execute permission:

sudo chmod +x /usr/local/bin/docker-compose

Verify the installation:

docker-compose --version

Expected output:

docker-compose version 1.25.5, build 8a1c60f6

Running a container with Docker Compose

Create a directory for the test project and navigate into it:

mkdir hello-world
cd hello-world

Create a docker-compose.yml file:

nano docker-compose.yml

Add the following content and save the file:

my-test:
  image: hello-world

Start the container:

docker-compose up

After the image is pulled, Docker will print a confirmation message:

Hello from Docker!
This message shows that your installation appears to be working correctly.

Common commands

List local images:

docker images

List active containers:

docker ps

List all containers including stopped ones:

docker ps -a

Start containers in the background:

docker-compose up -d

List containers in the current project:

docker-compose ps

Example output:

        Name            Command   State    Ports
------------------------------------------------
hello-world_my-test_1   /hello    Exit 0

Stop all containers in the current project:

docker-compose stop

Help

If you have any questions or need assistance, please contact us through the ticket system — we're always here to help!

Need help?Our engineers will help you free of charge with any question in minutesContact us