compose: `docker: 'compose' is not a docker command` when installing using convenience scripts
Description of the issue
I’m confused by the instructions for installing compose V2 on Linux and the convenience scripts don’t result in a working docker compose
.
This is kinda complicated just to get a working docker compose
, would be nice if it all worked with convenience scripts.
Really my goal is to add the alias docker-compose
(from https://github.com/docker/compose-switch) but I think I need docker compose
working first?
Context information (for bug reports)
- [X ] Using Compose V2
docker compose ...
- Using Compose V1
docker-compose ...
Output of docker(-)compose version
none yet trying to install
Output of docker version
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Client: Docker Engine - Community
Cloud integration: 1.0.17
Version: 20.10.8
API version: 1.41
Go version: go1.16.6
Git commit: 3967b7d
Built: Fri Jul 30 19:54:27 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Steps to reproduce the issue
I’m assuming I should be able to install the docker
/ docker compose
command line client inside a Linux container (I do that with docker and V1 docker-compose). Of course I’m only trying to run the docker client, the docker server is not running in the container.
- Create a Linux container on which you want the docker cli with the V2 compose subcommand. Btw it seems important that these convenience scripts work on centos/compatible too.
% docker run -ti ubuntu:20.04 bash
root@d8f753341dec:/# apt-get update && apt-get install -y curl
root@d8f753341dec:/# docker version
Client: Docker Engine - Community
Version: 20.10.8
API version: 1.41
Go version: go1.16.6
Git commit: 3967b7d
Built: Fri Jul 30 19:54:27 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
- Install the V2 docker compose cli:
root@d8f753341dec:/# curl -L https://raw.githubusercontent.com/docker/compose-cli/main/scripts/install/install_linux.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
Running checks... 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 5982 100 5982 0 0 31650 0 --:--:-- --:--:-- --:--:-- 31819
Checks passed!
Downloading CLI...
Downloaded CLI!
Installing CLI...
Done!
- I’d expect that to make
docker compose
work, but it does not.
root@d8f753341dec:/# docker compose version
docker: 'compose' is not a docker command.
See 'docker --help'
Observed result
docker: 'compose' is not a docker command.
Expected result
% docker compose version
Docker Compose version v2.0.0-rc.3
Additional information
Docker for Mac 4.0.2
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 25
Since this page is now ranking for
docker: 'compose' is not a docker command
on Google, here’s how you fix it on Ubuntu:in case you installed docker and docker-compose v2 with homebrew on OSX and getting
docker: 'compose' is not a docker command
then you need to run these commands:
@keunes
The instructions on the website assume installation on an x86_64 platform. Your Raspberry Pi will instead require an armhf / aarch64 binary. You’ll need to run these commands instead:
For Raspberry Pi 1, 2, or later versions running a 32-bit (armv7) operating system:
For Raspberry Pi 3 or 4 running a 64-bit (aarch64) operating system:
THANK YOU THANK YOU THANK YOU
Compose Switch is indeed a translator to offer a smooth transition for
docker-compose
commands to actually run Compose V2, so the later need to be installed first.Linux installation is documented here: https://github.com/docker/compose/tree/v2#linux Basically, as a CLI plugin, you just need to download the Compose V2 binary and place it in the
cli-plugins
directory asdocker-compose
.Try with (Ubuntu 20.04.6):
@ndeloof @jamshid Sorry to bug you - I am trying to install docker compose V2 on Raspberry Pi OS, and I am experiencing the same issue: I get
docker: 'compose' is not a docker command.
despite following the steps in the docs.From the OP’s reaction it seems a solution is suggested above, but it’s too cryptic for me to understand 😃 It would be great to have some further instructions, if anything needs to be done differently than what is written in the docs, or if I need to do something extra after.
All the best
Adding to @dmshvetsov answer, if you use Homebrew to install docker-compose you can use its CLI to define the
docker-compose
installation directory during the symlink creation. Also, it is necessary to createDOCKER_CONFIG
environment variable as described on “Install The Plugin Manually” section on Docker Compose documentationYou can also add
DOCKER_CONFIG
on your shell rc file (like.zshrc
or.bashrc
) to prevent setting it every time you want to use Docker Compose.Thanks @ndeloof ok I get it now. FYI this is what I’m using in my Dockerfile to get a working docker client and V2
docker compose
with the aliasdocker-compose
.Build outputs:
Install it using
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
Test it
docker compose version
Source
Note to self and others: if when trying to run docker compose you get an error like below, then set your system to Manage Docker as a non-root user. After that I didn’t have the error any-more.
@gopalmani If you have installed
docker-compose
you can use that command instead ofdocker compose
. Alternatively, you can remove bothdocker
anddocker-compose
, thenbrew install docker --cask
to install Docker Desktop, which also installs the CLI tools needed to rundocker compose
.sudo apt-get install docker-compose-plugin Reading package lists… Done Building dependency tree… Done Reading state information… Done E: Unable to locate package docker-compose-plugin
arch:
pacman -S docker-compose
Any help on mac, tried Installing both
docker
anddocker-compose
via homebrew, still no luck.Thanks, worked like a charm.
Keep in mind that for Ubuntu on a Raspberry Pi 2, at least,
$(uname -m)
will returnarmv7l
instead ofarmv7
. The binary will run on the platform, regardless.