3

I installed docker engine and docker compose in Ubuntu Linux 20.04LTS.

ubuntu@ip-10-0-2-13:~/myapp/src$ docker-compose -v
docker-compose version 1.27.4, build 40524192

I also ran beloe command to make executable of docker-compose

ubuntu@ip-10-0-2-13:~/myapp/src$ sudo chmod +x /usr/local/bin/docker-compose 

But when I execute the docker-compose command, still get permission denied error.

ubuntu@ip-10-0-2-13:~/myapp/src$ docker-compose down
WARNING: The VERSION_TAG variable is not set. Defaulting to a blank string.
Traceback (most recent call last):
  File "urllib3/connectionpool.py", line 677, in urlopen
  File "urllib3/connectionpool.py", line 392, in _make_request
  File "http/client.py", line 1252, in request
  File "http/client.py", line 1298, in _send_request
  File "http/client.py", line 1247, in endheaders
  File "http/client.py", line 1026, in _send_output
  File "http/client.py", line 966, in send
  File "docker/transport/unixconn.py", line 43, in connect
PermissionError: [Errno 13] Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "requests/adapters.py", line 449, in send
  File "urllib3/connectionpool.py", line 727, in urlopen
  File "urllib3/util/retry.py", line 403, in increment
  File "urllib3/packages/six.py", line 734, in reraise
  File "urllib3/connectionpool.py", line 677, in urlopen
  File "urllib3/connectionpool.py", line 392, in _make_request
  File "http/client.py", line 1252, in request
  File "http/client.py", line 1298, in _send_request
  File "http/client.py", line 1247, in endheaders
  File "http/client.py", line 1026, in _send_output
  File "http/client.py", line 966, in send
  File "docker/transport/unixconn.py", line 43, in connect
urllib3.exceptions.ProtocolError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker/api/client.py", line 205, in _retrieve_server_version
  File "docker/api/daemon.py", line 181, in version
  File "docker/utils/decorators.py", line 46, in inner
  File "docker/api/client.py", line 228, in _get
  File "requests/sessions.py", line 543, in get
  File "requests/sessions.py", line 530, in request
  File "requests/sessions.py", line 643, in send
  File "requests/adapters.py", line 498, in send
requests.exceptions.ConnectionError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "bin/docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 67, in main
  File "compose/cli/main.py", line 123, in perform_command
  File "compose/cli/command.py", line 69, in project_from_options
  File "compose/cli/command.py", line 132, in get_project
  File "compose/cli/docker_client.py", line 43, in get_client
  File "compose/cli/docker_client.py", line 170, in docker_client
  File "docker/api/client.py", line 188, in __init__
  File "docker/api/client.py", line 213, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied'))
[19602] Failed to execute script docker-compose

Can you help to solve this problem?

4 Answers 4

12

If you want to run the service without being root, you should read this https://docs.docker.com/engine/install/linux-postinstall/

You can add your user to the docker group with sudo usermod -aG docker $USER

Then you log out and log in and you're ready to go !

Sign up to request clarification or add additional context in comments.

1 Comment

For me it only works if I run new terminal session after that (in my case it was about reconnecting to an ec2 via ssh, since I was doing it remotely)
3

Have you tried running the docker-compose up command with sudo?

eg: sudo docker-compose up

2 Comments

Yes, I tried sudo. sudo does work, but I want to not sudo.
You need to add your user to the docker group then. Following this should resolve: stackoverflow.com/questions/48957195/…
1

I was struggling with this issue too.

I did not want to use sudo, because the containers do not show up in Docker Desktop. (Docker Desktop in Ubuntu not showing containers those are build with sudo privilege)

Then I discovered that "docker compose" (without the dash) is the updated version of "docker-compose" (Difference between "docker compose" and "docker-compose").

With "docker compose" it worked without the permission denied problem.

1 Comment

You just saved me from hours of hair pulling. Legend!
0
  1. Edit /etc/group by using vim or nano(my example by using nano).
sudo nano /etc/group
  1. Add your own user_group to docker group(my user group is "reza").
reza:x:1000:
sambashare:x:136:
testuser1:x:1002:
vboxsf:x:999:reza
vboxdrmipc:x:998:
docker:x:997:reza
  1. Save & exit (ctrl+x then press y then hit enter).
  2. Restart your machine.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.