


This allows you to run docker commands as non-root-user without using sudo all the time. When you run any docker command on Linux, the docker binary will try to connect to /var/run/docker.sock. See What does sudo usermod -a -G group $USER do on Linux? for details on what this command changes on your system and what the parameters mean. Uli sudo docker ps) – the error should now have disappeared. Running groups should show you that you now belong to the docker group: $ groups In order to add it to the docker group, run sudo usermod -a -G docker $USERĪfter running that command, you need to logout and log back in to your computer (or terminate your SSH session and re-connect in case you are logged in using SSH) – else, the group change does not take effect. The issue here is that the user you’re running the command as is not a member of the docker group. sudo docker ps) will solve the issue temporarily. You are running a command like docker ps but you get this error message: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get dial unix /var/run/docker.sock: connect: permission denied Solution:Īs a quick fix, running the command as root using sudo (e.g. Systemctl enable my-service # -> rvice, use whatever you named your file as Posted by Uli Köhler in Container, Docker, Linux replace /home/uli/mydockerservice/docker-compose.yml by your YML path).Īfter that, you can start your service using sudo systemctl start my-service # -> rvice, use whatever you named your file asĪnd optionally enable it at bootup: systemctl enable docker # Docker is required for your service so you need to enable it as well! Set the correct path for your docker-compose YML config file in all the Exec…=… lines (i.e.Define a name for your service that should be reflected in both the service filename and the Description=.Ensure that the user you want to run docker-compose as ( uli in this example) is a member of the docker group ( sudo usermod -a -G docker ), and set the correct user in the User=.Check if you have docker-compose in /usr/local/bin/docker-compose (as I do, because I use the docker-ce installation from the official docker repositories for Ubuntu 18.04) or in /usr/bin/docker-compose (in which case you need to set the correct docker-compose path in all 3 places in the service file).In order to get it up and running for your application, you need to modify a couple of things: # Shutdown container (if running) when unit is stoppedĮxecStartPre=/usr/local/bin/docker-compose -f /home/uli/mydockerservice/docker-compose.yml down -vĮxecStart=/usr/local/bin/docker-compose -f /home/uli/mydockerservice/docker-compose.yml upĮxecStop=/usr/local/bin/docker-compose -f /home/uli/mydockerservice/docker-compose.yml down -v Here’s my template for running a docker-compose service as a systemd service: # Save as e.g.
