28
(base) a@a-ThinkPad-T440:~$ docker-compose version
bash: /usr/local/bin/docker-compose: Permission denied

I have big problem with docker-compose, I tried to upgrade docker-compose to 1.25 with curl but now I have no permission for docker-compose (I have linux ubuntu)

Shubham
  • 2,705
  • 3
  • 21
  • 35
Z.Dubeau
  • 295
  • 1
  • 3
  • 8
  • 1
    How did you upgrade `docker-compose` with `curl`? What command did you run? – Shubham Dec 10 '19 at 10:41
  • 1
    How did you try to upgrade docker-compose? Does `/usr/bin/docker-compose --version` work? – KamilCuk Dec 10 '19 at 10:42
  • 2
    I had a similar problem where I followed the Linux install steps but the auto-created `docker` group didn't gain permissions to execute docker-compose. For me this fixed it (without opening it to any user): `sudo usermod -aG docker $USER` to add myself to docker group, `sudo chgrp docker /usr/local/bin/docker-compose` to give docker-compose to docker group, `sudo chmod 750 /usr/local/bin/docker-compose` to allow docker group users to execute it – user56reinstatemonica8 May 04 '20 at 12:54

1 Answers1

65

As far as I can understand you are using docker's source to install docker-compose and you forgot the second step. Source for complete installation.

As second step states. Apply executable permissions to the binary:

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

In addition to the comments provided in the question

sudo usermod -aG docker $USER                  # to add myself to docker group
sudo chgrp docker /usr/local/bin/docker-compose     # to give docker-compose to docker group,
sudo chmod 750 /usr/local/bin/docker-compose   # to allow docker group users to execute it

You might want to try running newgrp docker

Zlatan Omerović
  • 3,515
  • 4
  • 34
  • 63
adamkgray
  • 1,303
  • 8
  • 24
  • 4
    For unknown reasons I needed a restart before the above worked. – shad0w_wa1k3r Dec 27 '20 at 15:00
  • 1
    @shad0w_wa1k3r the updated docs I found tell you you need to either reboot or run `su - $USER` after making the group change. You could also log out then log in. This is very standard, any time you make a permissions change it isn't reflected until next login. – Stephan Samuel Feb 18 '21 at 18:27
  • 2
    In my case I also had to do: https://stackoverflow.com/a/68464690/1266873 – Koray Jul 28 '21 at 11:52
  • 1
    I found the instructions here https://docs.docker.com/engine/install/linux-postinstall/ – lesolorzanov Aug 03 '21 at 11:39
  • You might also want to restart the docker daemon when you create and add yourself to the docker group – ArthurKay Sep 19 '21 at 10:08