How to Install Docker Compose on Ubuntu 26.04

Docker Compose simplifies multi-container application management on Ubuntu 26.04, allowing you to define and run complex services with a single configuration file. This guide covers how to install Docker Compose on Ubuntu 26.04 using the most stable method via the Ubuntu repository, with an alternative approach for users requiring newer versions.

In this tutorial you will learn:

  • How to install Docker Compose V2 (with Docker) from Ubuntu repositories
  • How to install the latest Docker Compose from Docker’s official repository
  • How to verify your Docker Compose installation
  • How to create and run a basic multi-container application
  • How to troubleshoot Docker permission errors
Abstract illustration representing Docker Compose container orchestration on Ubuntu Linux with interconnected containers and configuration elements
Docker Compose simplifies multi-container application management on Ubuntu 26.04

Software Requirements

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 26.04 Resolute Raccoon
Software Docker Engine, Docker Compose V2
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user
TL;DR
Install Docker Compose V2 on Ubuntu 26.04 using sudo apt install docker-compose-v2.

Quick Steps to Install Docker Compose on Ubuntu 26.04
Step Command/Action
1. Update package index sudo apt update
2. Install Docker Compose V2 sudo apt install docker-compose-v2
3. Verify installation docker compose version

Install Docker Compose from Ubuntu Repository (Recommended)

The most stable method to install Docker Compose on Ubuntu 26.04 is through the official Ubuntu repositories. This approach provides a tested and integrated package that receives security updates through the standard system update mechanism. Additionally, the docker-compose-v2 package automatically installs Docker Engine (docker.io) as a dependency, making this a single-command installation.

  1. Update the package index: Ensure your system has the latest package information.
    $ sudo apt update
  2. Install Docker Compose V2: Install the docker-compose-v2 package from Ubuntu repositories.
    $ sudo apt install docker-compose-v2

    Ubuntu 26.04 automatically selects the docker-compose-v2 package when you request docker-compose. The installation pulls in docker.io (Docker Engine), containerd, and other required dependencies automatically. For more details on getting started with Docker, see our dedicated guide.

Terminal output showing sudo apt install docker-compose-v2 command on Ubuntu 26.04 with dependencies including docker.io, containerd, and bridge-utils being installed
Installing docker-compose-v2 automatically pulls Docker Engine and required dependencies

IMPORTANT
If Docker was not previously installed on your system, you need to add your user to the docker group to run Docker commands without sudo. Run sudo usermod -aG docker $USER followed by newgrp docker to apply the change immediately, or log out and back in.

The Ubuntu repository method is recommended for most users because it provides stability, automatic security updates, and seamless integration with your system’s package management.

Install Docker Compose from Docker Repository (Latest Version)

If you require a newer version of Docker Compose than what the Ubuntu repository provides, you can install it directly from Docker’s official APT repository. This method gives you access to the latest features and updates. Note that the Docker repository only provides the Compose plugin, so Docker Engine must be installed separately.

IMPORTANT
Only use this method if you specifically need features from a newer Docker Compose version. The Ubuntu repository version is sufficient for most use cases and offers better stability.

  1. Install Docker Engine: The Docker repository provides only the Compose plugin, not Docker itself. Install Docker Engine from Ubuntu repositories first.
    $ sudo apt install docker.io
  2. Add your user to the docker group: Allow running Docker commands without sudo.
    $ sudo usermod -aG docker $USER
    $ newgrp docker

    Alternatively, log out and back in for the group change to take effect.

  3. Install prerequisite packages: Add packages required for downloading over HTTPS.
    $ sudo apt install ca-certificates curl gnupg
  4. Add Docker’s official GPG key: Download and store Docker’s signing key.
    $ sudo install -m 0755 -d /etc/apt/keyrings
    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    $ sudo chmod a+r /etc/apt/keyrings/docker.gpg
  5. Add Docker repository: Configure the Docker APT repository for Ubuntu 26.04.
    $ echo \
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
      $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
      sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  6. Update and install: Refresh the package index and install Docker Compose plugin.
    $ sudo apt update
    $ sudo apt install docker-compose-plugin

For comprehensive documentation on Docker’s installation options, consult the official Docker Compose installation guide.

Terminal output showing sudo apt install docker-compose-plugin command on Ubuntu 26.04 installing docker-compose-plugin and docker-buildx-plugin from Docker repository
Installing docker-compose-plugin from Docker’s repository provides the latest version

Verify Docker Compose Installation on Ubuntu 26.04

After installation, verify that Docker Compose is properly installed and accessible. Docker Compose V2 integrates as a Docker CLI plugin, meaning you invoke it using docker compose (with a space) rather than the legacy docker-compose command.

$ docker compose version

The version number may differ depending on whether you installed from Ubuntu repositories or Docker’s repository. Both methods provide fully functional Docker Compose V2 installations.

Terminal output showing docker compose version command returning Docker Compose version v5.0.2 on Ubuntu 26.04
Docker Compose v5.0.2 successfully installed and verified on Ubuntu 26.04

Basic Docker Compose Usage Example

To demonstrate Docker Compose functionality, create a simple web server displaying a branded page. This example illustrates volume mounting and service configuration in a Docker Compose YAML file.

  1. Create a project directory: Set up a dedicated folder for your Docker Compose project.
    $ mkdir ~/compose-demo && cd ~/compose-demo
  2. Create an index.html file: Create a simple HTML page to be served by the web server.
    $ nano index.html

    Add the following content:

    <h1>Welcome to LinuxConfig.org</h1>
    <p>Docker Compose is working on Ubuntu 26.04!</p>
  3. Create a compose.yaml file: Define the web service in a Docker Compose configuration file.
    $ nano compose.yaml

    Add the following content:

    services:
      web:
        image: nginx:alpine
        ports:
          - "8080:80"
        volumes:
          - ./index.html:/usr/share/nginx/html/index.html:ro
  4. Start the service: Launch the container in detached mode.
    $ docker compose up -d

    Docker Compose pulls the required Docker images and starts the container according to your configuration.

  5. Test the web server: Open a browser and navigate to http://localhost:8080 or use curl.
    $ curl http://localhost:8080
  6. Stop and remove containers: When finished, clean up the running services.
    $ docker compose down
Terminal showing complete Docker Compose workflow with docker compose up pulling nginx:alpine image, docker compose ps showing running container, curl displaying Welcome to LinuxConfig.org message, and docker compose down removing containers
Complete Docker Compose workflow: creating project, starting services, testing, and cleanup

For more advanced Docker Compose workflows, including restarting Docker services and working with Docker Hub, explore our related tutorials.

Troubleshooting

Permission Denied Error

If you encounter the following error when running Docker commands:

$ docker ps
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

This indicates your user is not a member of the docker group. Resolve this by adding your user to the group:

$ sudo usermod -aG docker $USER
$ newgrp docker

The newgrp docker command activates the group membership in your current session. Alternatively, log out and back in for the change to take effect permanently across all terminal sessions.

Conclusion

You have successfully installed Docker Compose on Ubuntu 26.04. The recommended approach using sudo apt install docker-compose-v2 provides a stable, well-maintained installation suitable for most deployment scenarios. For users requiring cutting-edge features, the Docker repository method offers access to the latest versions. With Docker Compose configured, you can now efficiently manage multi-container applications using declarative YAML configuration files.

Frequently Asked Questions

  1. What is the difference between docker-compose and docker compose? Docker Compose V1 used a standalone docker-compose binary (with hyphen), while Docker Compose V2 integrates as a Docker CLI plugin invoked with docker compose (with space). Ubuntu 26.04 ships Docker Compose V2, which is the current standard. The functionality is essentially identical, but V2 offers better performance and tighter Docker integration.
  2. Can I use both Ubuntu repository and Docker repository versions simultaneously? No, you should choose one installation method. Installing from both sources creates package conflicts and version inconsistencies. If you need to switch methods, first remove the existing installation before proceeding with the alternative approach.
  3. How do I update Docker Compose installed from Ubuntu repositories? Docker Compose updates automatically with your regular system updates. Run sudo apt update && sudo apt upgrade to receive the latest version available in Ubuntu repositories. For Docker repository installations, the same commands apply but pull updates from Docker’s repository instead.
  4. Do I need to install Docker Desktop to use Docker Compose on Ubuntu 26.04? No, Docker Desktop is optional. Docker Compose works perfectly with Docker Engine alone. Docker Desktop provides a graphical interface and additional features but is not required for command-line Docker Compose usage.