Docker Compose Permission Denied


I had no issues running docker, ran a script for something work related (I believe it might’ve installed another docker instance?) and now when I run “docker-compose up -d” on root user, it says the ports are already being used.

docker-compose ls returns only 1 docker-compose file,
docker compose ls is the same.

I never used “docker compose” and strictly used “docker-compose” until today, perhaps this is the issue?

I tried “docker-compose down” and I get the following error:

Please note on the image above I am using root user.

here is my output of “dpkg -l | grep docker”
ii docker-buildx-plugin 0.10.5-1~ubuntu.20.04~focal amd64 Docker Buildx cli plugin.
ii docker-ce 5:24.0.2-1~ubuntu.20.04~focal amd64 Docker: the open-source application container engine
ii docker-ce-cli 5:24.0.2-1~ubuntu.20.04~focal amd64 Docker CLI: the open-source application container engine
ii docker-ce-rootless-extras 5:24.0.2-1~ubuntu.20.04~focal amd64 Rootless support for Docker.
ii docker-compose-plugin 2.18.1-1~ubuntu.20.04~focal amd64 Docker Compose (V2) plugin for the Docker CLI.

Would recommend checking to see which ports are in use. Running netstat -ano in Powershell or CMD (on Windows) will show all ports in use. If you’re on Linux run sudo netstat -tunlp. From there you can kill whatever processes show up on those ports and try running it again.

This can’t be the problem. The state is stored in the docker engine, not in docker compose (v2.x) or docker-compose (v1.x)

Have you checked if the docker snap package is installed? snap list docker

Furthermore, please share the outputs of following commands:

docker info
sudo docker info


Snap list docker returns nothing.
It seems like there is an error at the bottom here. I’ve spent about an hour researching how to fix the issue and it doesn’t seem to return any positive results.

Here are the steps I’ve done to try and resolve “Cannot connect to the Docker daemon at unix:///var/run/docker.sock”

  1. Ensured /var/run/docker.sock has the right permissions
  2. Ensured systemctl status docker has no errors and is running.

Client: Docker Engine - Community
Version: 24.0.2
Context: default
Debug Mode: false
buildx: Docker Buildx (Docker Inc.)
Version: v0.10.5
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.18.1
Path: /usr/libexec/docker/cli-plugins/docker-compose

ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info

Never mind, ignore the one without sudo. Since you specificly mentioned root, I thought you might have added an unprivileged user to the docker group, but the error message indicates you didn’t.

So please share the output of sudo docker info (or without sudo if you execute the command as root).

1 Like

Hi i am facing a problem regarding the framework 4.5 dockerization . i am using windows docker desktop. when inthe running time i am getting the result and all file i can see inthe container . if iam close the visual studio i cannot find the project files inthe docker container . is there any sujessions to use docker compose file .