I'm new to docker and I don't manage to connect to a container.

If I understand properly I have to connect to SSH to my actual host then use this :

docker exec -it pihole-pihole1(name_of_the_container) command

but then when I do this :

docker exec -it pihole-pihole1 sudo nano /etc/pihole/adlists.list

I have this error :

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.29/containers/pihole-pihole1/exec: dial unix /var/run/docker.sock: connect: permission denied

How should I proceed ?

  • Are you running the command as root user or normal user ? If normal user, make sure you have added him into docker group. – rɑːdʒɑ Oct 4 '18 at 11:36

You need to add your user to Docker group on the host machine:

sudo usermod -aG docker <username>

Logout, login again, it should work. Otherwise you need to insert sudo before all of your docker commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.