Machine: Question: Permission Denied on curl and save for docker compose

Created on 27 Feb 2015  ·  30Comments  ·  Source: docker/machine

In the instructions for installing docker-compose, you can do :

curl -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

But you cannot intall it because:

zsh: permission denied: /usr/local/bin/docker-compose

I don't want to do sudo, because I wanted it to be like my previous installs and usage of docker

docker <command>

No sudo...

What is the proper way of setting it up?

Most helpful comment

in terminate input sudo chown -R $(whoami) /usr/local/bin

All 30 comments

I believe you meant https://github.com/docker/compose. @aanand ?

Most likely your /usr/local/bin directory isn't writable by you. Either chmod/chown it, or download docker-compose somewhere writable and sudo cp it in.

You won't need sudo to run it, just to install it.

I'm having this problem too and I'm kinda linux newbie :) Can someone help me?

@luisrudge for compose or machine?

Oh, sorry! It's for compose!

@luisrudge ok np :) Mind if I close this one?

Yes! Thanks!

i'm facing same issue for docker machine, please redirect me to the solution @ehazlett

@joeyhipolito @aanand kindly help

@tarun6006 The problem/solution is likely the same:

Most likely your /usr/local/bin directory isn't writable by you. Either chmod/chown it, or download docker-machine somewhere writable and sudo cp it in.

You won't need sudo to run it, just to install it.

in terminate input sudo chown -R $(whoami) /usr/local/bin

Oh thanks @zhangqinghe it fixed the problem for me

I found this approach easier.

@zhangqinghe this solves the problem. thanks.

To me sudo -i before, solved the problem.

@zhangqinghe thanks . this solves my problem.

please type
sudo chmod -Rf 777 /usr/local/bin
it's work

Please DO NOT do this. This will have far-reaching permission changes which are likely beyond the scope of what you'd actually like to accomplish.

sudo chown -R $(whoami) /usr/local/bin

Please DO NOT do this either (it will change the owner of every single file recursively in /usr/local/bin to the user you are currently running as). It's WAY overkill. I can't emphasize this enough.

Doing something like this is very likely to blow up in your face eventually. In /usr/local/bin on my Mac some files are owned by nathanleclaire and some are owned by root. The programs that put them there and rely on them probably expect it to stay this way. The suggested command above will totally decimate these carefully layed out file ownerships.

Instead, if needed, consider this type of operation instead. Save the file to a directory you own and then cp / mv it.

$ curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` \
    >~/docker-compose
$ chmod +x ~/docker-compose
$ sudo mv ~/docker-compose /usr/local/bin/docker-compose

Much safer with much less far-reaching consequences.

From Docker documentation:

Note: If you get a “Permission denied” error, your /usr/local/bin directory probably isn’t writable and you’ll need to install Compose as the superuser. Run sudo -i, then the two commands below, then exit

nathanleclaire suggestion worked for me. Thanks

Google brings me here....

Please, please PLEASE... use the @nathanleclaire solution

What about this:
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

sudo usermod -aG docker your-user
Is this a good idea?

make sure docker-compose is executable (chmod +x /usr/local/bin/docker-compose)

No need to mess with permissions on all files inside /usr/local/bin
Do not do

sudo chown -R $(whoami) /usr/local/bin

Do this instead

sudo -i
curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod 755 /usr/local/bin/docker-compose
exit

Please use @nathanleclaire 's solution, it works very well for me.

make sure docker-compose is executable (chmod +x /usr/local/bin/docker-compose)

this worked on Ubuntu 18.04

I found this approach easier.

this worked for me :D

To me sudo -i before, solved the problem.

This (or any of the others mentioning sudo -i ) should be the accepted answer and not the just chown the entire /usr/local/bin

For what it's worth: the permission denied: docker-compose error occurred to me after an upgrade of Docker. A minute earlier everything was still working fine, so my permissions were all in order.

After I started the (now upgraded) Docker desktop application and authorized it when asked for my administrator password, the error was gone. So Docker fixed the permissions itself.

This code alone can solve this problem
sudo chmod +x /usr/local/bin/docker-compose

Was this page helpful?
0 / 5 - 0 ratings