45
(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,847
  • 4
  • 24
  • 37
Z.Dubeau
  • 463
  • 1
  • 4
  • 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
  • 3
    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
    This question is about "softeware tools primarily used by programmers" so maybe the Question Closing Police need to lighten up a bit – Greg Woods Aug 28 '22 at 07:33

1 Answers1

103

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,863
  • 4
  • 39
  • 67
adamkgray
  • 1,717
  • 1
  • 10
  • 26
  • 6
    For unknown reasons I needed a restart before the above worked. – shad0w_wa1k3r Dec 27 '20 at 15:00
  • 3
    @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
  • 3
    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 – The Nerdy Geek Sep 19 '21 at 10:08