Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: 'compose' is not a docker command when installing using convenience scripts #8630

Closed
1 task
jamshid opened this issue Sep 17, 2021 · 31 comments
Closed
1 task

Comments

@jamshid
Copy link

jamshid commented Sep 17, 2021

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.

  1. 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?

  1. 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!
  1. 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

@ndeloof
Copy link
Contributor

ndeloof commented Sep 17, 2021

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 as docker-compose.

@jamshid
Copy link
Author

jamshid commented Sep 17, 2021

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 alias docker-compose.

ENV DOCKER_VERSION 20.10.7
RUN curl -sSLf https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz | tar -xzvf - docker/docker && chmod +x docker/* && mv docker/* /bin

RUN test "$(uname -m)" = "aarch64" && TARGET_ARCH=arm64 || TARGET_ARCH=amd64 ; \
    mkdir -p ~/.docker/cli-plugins && \
    curl -fsSL "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSEV2_VERSION-v2.0.0-rc.3}/docker-compose-linux-${TARGET_ARCH}" -o ~/.docker/cli-plugins/docker-compose && \
    chmod +x ~/.docker/cli-plugins/docker-compose && \
    curl -fsSL -o /usr/local/bin/docker-compose https://github.com/docker/compose-switch/releases/download/v1.0.2/docker-compose-linux-${TARGET_ARCH} && \
    chmod +x /usr/local/bin/docker-compose && \
    docker --version && docker compose version && docker-compose version

Build outputs:

Docker version 20.10.7, build f0df350
Docker Compose version v2.0.0-rc.3
Docker Compose version v2.0.0-rc.3

@keunes
Copy link

keunes commented Mar 19, 2022

@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

@nathan-osman
Copy link

@keunes

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.

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:

  1. DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
    mkdir -p $DOCKER_CONFIG/cli-plugins
  2. For Raspberry Pi 1, 2, or later versions running a 32-bit (armv7) operating system:

    curl -SL https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-linux-armv7 -o $DOCKER_CONFIG/cli-plugins/docker-compose

    For Raspberry Pi 3 or 4 running a 64-bit (aarch64) operating system:

    curl -SL https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-linux-aarch64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
  3. chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose

@keunes
Copy link

keunes commented Mar 20, 2022

Thank you so much @nathan-osman, that worked :)
So it seems that just the URL to the artifact in the docs is 'wrong' (for a specific architecture). The instructions for V1 contain $(uname -m) in the download URL, which automatically injects the right architecture in the URL. I'll make a PR to update the V2 link with that as well.

@nathan-osman
Copy link

nathan-osman commented Mar 20, 2022

The instructions for V1 contain $(uname -m) in the download URL, which automatically injects the right architecture in the URL.

Keep in mind that for Ubuntu on a Raspberry Pi 2, at least, $(uname -m) will return armv7l instead of armv7. The binary will run on the platform, regardless.

@keunes
Copy link

keunes commented Mar 20, 2022

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.

pi@raspberry:/nextcloud-docker $ docker compose up
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json?all=1&filters=%7B%22label%22%3A%7B%22com.docker.compose.project%3Dnextcloud-docker%22%3Atrue%7D%7D&limit=0": dial unix /var/run/docker.sock: connect: permission denied

@mrfy
Copy link

mrfy commented Apr 1, 2022

Thank you @nathan-osman ! 👍

@ruurtjan
Copy link

ruurtjan commented May 31, 2022

Since this page is now ranking for docker: 'compose' is not a docker command on Google, here's how you fix it on Ubuntu:

sudo apt-get install docker-compose-plugin

@dmshvetsov
Copy link

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:

$ mkdir -p ~/.docker/cli-plugins
$ ln -sfn /opt/homebrew/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose

@KrystalZhang612
Copy link

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:

$ mkdir -p ~/.docker/cli-plugins
$ ln -sfn /opt/homebrew/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose

THANK YOU THANK YOU THANK YOU

@goldblade
Copy link

thanks @ruurtjan It's worked

@anhtuank7c
Copy link

Since this page is now ranking for docker: 'compose' is not a docker command on Google, here's how you fix it on Ubuntu:

sudo apt-get install docker-compose-plugin

Thanks

@MarceloLeite2604
Copy link

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:

$ mkdir -p ~/.docker/cli-plugins
$ ln -sfn /opt/homebrew/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose

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 create DOCKER_CONFIG environment variable as described on "Install The Plugin Manually" section on Docker Compose documentation

DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
ln -sfn $(brew --prefix docker-compose)/bin/docker-compose $DOCKER_CONFIG/cli-plugins/docker-compose

You 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.

echo -e "\nexport DOCKER_CONFIG=\${DOCKER_CONFIG:-\$HOME/.docker}" >> ~/.zshrc

@PSNAppz
Copy link

PSNAppz commented Feb 19, 2023

DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose

Install it using

sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose

Test it

docker compose version

Source

@jamesbright
Copy link

Since this page is now ranking for docker: 'compose' is not a docker command on Google, here's how you fix it on Ubuntu:

sudo apt-get install docker-compose-plugin

Thanks, worked like a charm.

@jrsmarcilio
Copy link

I checked that the 'docker-compose' plugin was installed in the root user.

sudo ls /root/.docker/cli-plugins
# docker-compose

In that case:

sudo cp -r /root/.docker/cli-plugins /home/$USER/.docker/
docker compose version
# Docker Compose version v2.3.3

sorry for my english

@hillaryomondi
Copy link

The command below worked:

sudo apt-get install docker-compose-plugin

@gopalmani
Copy link

Any help on mac, tried Installing both docker and docker-compose via homebrew, still no luck.

@paoloose
Copy link

arch: pacman -S docker-compose

@lucasjinreal
Copy link

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

@engrjislam
Copy link

Try with (Ubuntu 20.04.6):

sudo apt-get update
sudo apt-get install docker-compose-v2

@ndeloof
Copy link
Contributor

ndeloof commented Nov 24, 2023

@engrjislam please note docker-compose-v2 is a canonical-maintained system package, not the official one from Docker Inc distributed on https://download.docker.com (see https://docs.docker.com/engine/install/ubuntu/)

@deepfriedmind
Copy link

Any help on mac, tried Installing both docker and docker-compose via homebrew, still no luck.

@gopalmani If you have installed docker-compose you can use that command instead of docker compose. Alternatively, you can remove both docker and docker-compose, then brew install docker --cask to install Docker Desktop, which also installs the CLI tools needed to run docker compose.

@mhomesh
Copy link

mhomesh commented Dec 28, 2023

With Apple macbook Air you can directly install the same using the following dmg file easy setup and it works 100%
https://docs.docker.com/desktop/install/mac-install/

@dinshaw
Copy link

dinshaw commented Jan 22, 2024

Still not working. Just installed 4.26.1 (131620) on new M2 MacbookPro with Sonoma 14.2.1 (23C71).

  docker compose
docker: 'compose' is not a docker command.
See 'docker --help'

@simibac
Copy link

simibac commented Apr 13, 2024

None of the solutions above worked for me. The official documentation worked: https://docs.docker.com/engine/install/debian/

@ps-dmaksimovic
Copy link

I had this problem because I use 2 users on macos. I had to manually run Docker Desktop on the 2nd user and go through initial setup before docker-compose started working on this user too.

@its-bessner
Copy link

This did the trick for me on Ubuntu:

sudo apt install -y docker.io docker-compose-v2

After that I was able to use docker compose like this:

docker compose up -d

Hope this helps

@RobertoGDev
Copy link

Just to add information. You must make sure you have Docker Desktop open, otherwise the Docker engine and its plugins will not run.

@ivantoniev
Copy link

ivantoniev commented Sep 17, 2024

For Mac, if you install docker and the compose plugin with homebrew, the post install prompt helpfully gives the answer to add the below to ~/.docker/config.json

"cliPluginsExtraDirs": [
  "/opt/homebrew/lib/docker/cli-plugins"
]

But the above symlink solution from dmshvetsov also worked. I went with the config.json though as advised by the plugin install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests