A2oz

How to Install Docker Compose in Ubuntu?

Published in Software Installation 2 mins read

You can install Docker Compose on Ubuntu using the following steps:

1. Update the System

Before installing Docker Compose, it's crucial to update your Ubuntu system to ensure you have the latest packages and dependencies. Execute the following command in your terminal:

sudo apt update

2. Install Docker Compose

Use the following command to download and install the latest version of Docker Compose from the official Docker repository:

sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://github.com/docker/compose/releases/latest | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+' | cut -d 'v' -f 2)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

3. Make Docker Compose Executable

Grant execute permissions to the Docker Compose binary:

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

4. Verify the Installation

To verify the installation, run the following command:

docker-compose --version

This will print the installed version of Docker Compose, confirming its successful installation.

5. Use Docker Compose

Now you can use Docker Compose to define and manage multi-container Docker applications.

Here's an example of a simple Docker Compose file:

version: "3.9"

services:
  web:
    image: nginx:latest
    ports:
      - "80:80"

To build and run the application defined in this file, use the following commands:

docker-compose build
docker-compose up -d

Conclusion

By following these steps, you can successfully install Docker Compose on your Ubuntu system and utilize its features to streamline your Docker application management.

Related Articles