title: 'Permission denied error in docker-compose on Linux: causes and solution' summary: 'The article explains why the "permission denied" error occurs when using docker-compose on Linux and provides several proven ways to fix it. You will learn how to add a user to the docker group, start the daemon, and configure socket permissions.' keywords:
- docker-compose permission denied
- docker-compose permission denied error on linux
- how to fix docker-compose without sudo
- add user to docker group
- docker daemon not running permission denied
- docker.sock permission denied
- docker-compose run as root
- EACCES docker-compose locale: ru_RU platform: linux related:
- /errors/linux/docker-daemon-not-running
- /guides/linux/install-docker-engine
- /errors/linux/docker-command-not-found section: Docker Errors severity: high tags:
- docker-compose
- error
- Linux
- permissions
- docker.sock
- docker group
- permission denied type: error updatedAt: '2026-02-17 11:33:12' howToTotalTime: PT10M
-`. If not, see Method 3.
- name: Run docker-compose without sudo
text: After completing steps 1-3, try running
docker-compose upin your project. The permission denied error should disappear.
What does the permission denied error mean in docker-compose
The permission denied error when running docker-compose on Linux occurs when the current user does not have read/write permissions on the Docker Unix socket (/var/run/docker.sock). This is the primary communication interface between clients (docker, docker-compose) and the Docker daemon (dockerd).
Typical error message:
ERROR: Can't connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
or
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
The error blocks the execution of any docker-compose command (up, down, ps, logs, etc.) because without access to the Docker daemon, it is impossible to manage containers.
Causes
- User is not a member of the
dockergroup
By default, access to/var/run/docker.sockis restricted to thedockergroup. If the user is not in this group, the system returnsEACCES(Permission denied). - Docker daemon is not running
If thedockerservice is stopped (systemctl status dockershowsinactive), the socket may be missing or inaccessible. - Incorrect permissions on the
/var/run/docker.socksocket
The socket owner should beroot:docker, and permissions should besrw-rw----(660). If permissions are changed (e.g., to777or644), access is compromised. - Running docker-compose as root via
sudowithout environment configuration
When usingsudo, environment variables (such asDOCKER_HOST) may be reset, leading to connection errors. - Using a remote Docker daemon without the correct
DOCKER_HOST
If Docker is configured on a remote host but theDOCKER_HOSTvariable is not set, docker-compose attempts to connect to the local socket without permissions.
Method 1: Add the user to the docker group (recommended)
This is the proper and secure solution. It gives the user access to Docker without using sudo.
- Add the current user to the
dockergroup:sudo usermod -aG docker $USER
The-aGflag adds the user to thedockergroup without removing them from other groups. - Apply the group changes:
- Option A: Log out and log back in (or restart the computer). This ensures the new group is activated in all sessions.
- Option B: In the current session, run
newgrp dockerto make thedockergroup active without logging out.
- Check group membership:
groups
The output should include thedockergroup. - Verify Docker access:
docker ps
If the command runs without errors, docker-compose will also work.
💡 Tip: After adding to the group, you may need to restart the terminal or session for the changes to take effect.
Method 2: Run docker-compose via sudo (temporary solution)
Use sudo to run docker-compose if you need a quick fix, but this is not recommended for daily use due to security risks.
sudo docker-compose up
Disadvantages:
- Containers run as root, giving them full access to the host system.
- Files created in the container will be owned by root, which can cause permission issues when later accessed by a regular user.
- Environment variables and configuration files (
.env) may be ignored.
⚠️ Important: Use this method only for testing or in isolated environments. For production, configure the
dockergroup.
Method 3: Change permissions on docker.sock socket (not recommended)
If for some reason you cannot add the user to the docker group, you can temporarily change the socket permissions. This reduces security because any user will gain access to the Docker daemon.
- Check current permissions:
ls -l /var/run/docker.sock
Example output:srw-rw---- 1 root docker 0 Feb 17 12:00 /var/run/docker.sock - Change permissions to 666 (access for all):
sudo chmod 666 /var/run/docker.sock
After this, thepermission deniederror will disappear, but any system user will be able to manage Docker. - Revert permissions after use:
sudo chmod 660 /var/run/docker.sock sudo chown root:docker /var/run/docker.sock
⚠️ Important: This method should only be used in controlled environments (e.g., in a test container) and temporarily. For permanent use, configure groups.
Method 4: Check and start the Docker daemon
If the Docker daemon is not running, even adding to the docker group will not help.
- Check the Docker service status:
systemctl status docker - If the service is inactive (
inactive), start it:sudo systemctl start docker - Enable Docker to start on system boot:
sudo systemctl enable docker - Restart docker-compose after starting the daemon.
Method 5: Fix docker-compose configuration (if using a remote host)
If Docker is configured on a remote host, ensure the DOCKER_HOST environment variable is set correctly.
- Set
DOCKER_HOST(example for TCP connection):export DOCKER_HOST=tcp://remote-host:2375
Or for TLS:export DOCKER_HOST=tcp://remote-host:2376 - Verify the connection:
docker info - Run docker-compose:
docker-compose up
💡 Tip: For permanent use, add
export DOCKER_HOST=...to~/.bashrcor~/.profile.
Frequently Asked Questions (FAQ)
Why does the error persist after adding to the docker group?
After adding to the group, you need to log out and log back in (or run newgrp docker). Without this, the session continues to use the old group list.
How do I check which group I am in?
Run groups or id -nG. If docker is not in the list, the user is not in the group.
What to do if the docker group is not created?
The docker group is created when Docker Engine is installed. If it doesn't exist, reinstall Docker:
sudo apt remove docker-ce docker-ce-cli containerd.io
sudo apt install docker-ce docker-ce-cli containerd.io
Can I add a user to the docker group without sudo?
No, changing groups requires root privileges. Use sudo or log in as root.
Why does docker ps work but docker-compose up does not?
Possibly, docker-compose is outdated or installed from a third-party repository with different permissions. Update docker-compose:
sudo apt upgrade docker-compose-plugin
Or use the built-in plugin: docker compose up.