Installing Docker Compose in CentOS 7

Docker Compose installation guide in CentOS 7

Modern web projects and enterprise systems are increasingly deployed on VPS or dedicated servers. This approach provides stability, scalability, and flexibility in managing infrastructure. To achieve this, containerization is widely used. One of the most popular tools is Docker, and for managing multi-container applications, developers often rely on Docker Compose.


Docker is a platform that automates the deployment and management of applications within operating system–level virtualization. It allows you to “package” an application together with all its dependencies into a container, which can then be run on any Linux system with kernel cgroups support. Docker also provides convenient tools for managing containers.

file


Docker Compose is a tool for defining and running multi-container applications. It uses a dedicated YAML file to describe services and their configuration parameters.

Key advantages of Docker Compose include:

  • Multiple isolated environments on a single host
  • Data persistence in volumes when containers are recreated
  • Restarting only changed containers
  • Easy use of environment variables

Installing Docker Compose

Before installing Docker Compose, make sure Docker itself is already installed. You can find a detailed installation guide here.

Check the latest release and, if necessary, update it using the following command:

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

Make the binary executable:

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

Verify the installation:

docker-compose --version

Example output:

docker-compose version 1.25.5, build 8a1c60f6

Running Your First Container with Docker Compose

As a quick demonstration, let’s use the test image hello-world from Docker Hub.

Create a directory and switch into it:

mkdir hello-world
cd hello-world

Create a docker-compose.yml file:

nano docker-compose.yml

Add the following content:

my-test:
  image: hello-world

Start the container:

docker-compose up

Note

Once the image has been pulled and the container started, you’ll see Docker’s greeting message:

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

Working with Containers

List local images:

docker images

View running containers:

docker ps

View all containers (including stopped ones):

docker ps -a

Essential Docker Compose Commands

Start containers in detached (background) mode:

docker-compose up -d

List all containers in the current Compose 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
Need help?Our engineers will help you free of charge with any question in minutesContact us