docker compose
rather than the deprecated docker-compose
.
When you run the command docker compose version
and see the message:
docker: 'compose' is not a docker command. See 'docker --help'
it signifies that Docker does not recognize the command as provided. This issue typically occurs because Docker Compose is either not installed, not recognized as a valid subcommand due to version or syntax issues, or is not properly set up in your environment.
The possibility of the error often stems from the Docker Compose component not being installed on your system. The installation process varies based on your operating system:
On Windows and macOS: If you are using Docker Desktop, Docker Compose is typically bundled as part of the installation package, especially with versions supporting Docker Compose V2. However, ensure that Docker Desktop is updated to the latest version which includes the correct version of Docker Compose.
On Linux: Docker may not include Docker Compose by default. While earlier installations used the standalone Docker Compose tool (often invoked as docker-compose
), recent developments require you to install Docker Compose as a CLI plugin, which introduces the V2 command syntax (docker compose
).
To check the installation status, perform the following commands:
# Check version using new syntax
docker compose version
# Alternatively, if you suspect the CLI plugin might not be correctly installed, try:
docker-compose --version
Using these commands will indicate whether the respective versions of Docker Compose are installed. If neither returns the version details, then Docker Compose might need to be installed or reinstalled.
Docker Compose V1 (invoked with docker-compose
) has been deprecated. Instead, the Docker community has standardized on Docker Compose V2, which uses the command docker compose
without the hyphen.
If you continue to use the old syntax on a Docker installation that primarily supports V2, the system may not recognize your input, leading to the error. Therefore, ensure you are using:
docker compose version
rather than:
docker-compose --version
Moreover, if for some reason your environment still relies on V1, you might want to consider transitioning to V2. Updating the syntax across all your scripts and documentation will improve compatibility and leverage ongoing improvements and support.
Another common cause of the error is the system’s PATH configuration not including the location where Docker Compose is installed. Without this, even if Docker Compose is correctly installed, the system might not be able to locate the executable.
To resolve this:
which docker-compose
or which docker
(to see where Docker CLI is installed). Confirm that the expected directory appears in your system’s PATH.
.bashrc
or .bash_profile
(or the corresponding shell configuration file).
Suppose Docker Compose is installed in /usr/local/bin
and that directory is not in your PATH, you can add it by appending the following line to your shell's configuration file:
# In ~/.bashrc or ~/.zshrc
export PATH="/usr/local/bin:$PATH"
# After editing, reload your shell configuration
source ~/.bashrc
For users of Docker Desktop (on Windows or macOS), ensuring that you have the latest version is crucial. Docker Desktop updates include bug fixes, new features, and better integration of tools such as Docker Compose.
To update Docker Desktop:
On Linux, you may need to explicitly install Docker Compose as part of the Docker Engine plugin system. Use the following commands to install the Docker Compose V2 plugin:
# Install the Docker Compose plugin
docker cli plugin install docker/compose
# Verify the installation
docker compose version
If you continue experiencing problems, consider fully reinstalling Docker Engine and Docker Compose. Uninstallation followed by a clean installation might resolve lingering configuration issues, especially if earlier installation attempts were corrupted.
For those who installed Docker Compose as a CLI plugin with Docker Engine, platform-specific issues or misconfigurations might cause the command to fail, even if the plugin is correctly installed.
To diagnose such issues, list the available Docker commands by executing:
docker --help
Check for any lines mentioning compose
in the displayed help information. If it is missing, it confirms an issue with plugin detection or installation.
Ensure that your Docker Engine version supports CLI plugins; often, older versions of Docker Engine might not support this integration reliably. Upgrading your Docker Engine might resolve the problem.
Step | Description | Example Command |
---|---|---|
Verify Installation | Check if Docker Compose is installed. | docker compose version |
Use Correct Syntax | Ensure use of docker compose instead of docker-compose . |
docker compose version |
PATH Check | Confirm that the installation directory is in your system's PATH. | echo $PATH (Linux/Mac) |
Reinstall Plugin | For Linux, install the Docker Compose V2 plugin if missing. | docker cli plugin install docker/compose |
Update Docker Desktop | Ensure that Docker Desktop is up to date (Windows/macOS users). | Use Docker Desktop update tool |
It is important to check installation paths as sometimes multiple Docker or Docker Compose versions can exist on a system due to past installations or conflicting package managers. Running:
which docker
and:
which docker-compose
can help determine which binaries are being called by default. If you find multiple paths, consider cleaning up the older versions to avoid confusion.
Always ensure that the installed Docker Engine version is compatible with the Docker Compose version you wish to use. Formulas for compatibility are provided in Docker’s official documentation, which explain the supported versions together.
If you find that your Docker Engine is outdated, upgrade to a current release version to fully support the latest features, including CLI plugins.
Use the following checklist as a reference guide when troubleshooting the issue:
docker compose
rather than docker-compose
.docker compose version
and review the output for version details.compose
appears among the available commands.