Bobcares

AWS EC2 docker permission denied – How to resolve

by | Jun 10, 2021

Wondering how to resolve AWS EC2 docker permission denied error? We can help you.

This error usually occurs if the user do not have enough permission.

At Bobcares we assist our customers with several AWS queries as part of our AWS Support Services for AWS users, and online service providers.

Today, let us discuss how our Support Techs resolved above error.

 

How to resolve AWS EC2 docker permission denied?

You may notice “permission denied” error while using docker commands from an EC2 instance.

Typical error might look as shown below:

docker: 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.26/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

The above error message tells you that your current user can’t access the docker engine, because of loacking permissions to access the unix socket to communicate with the engine.

Today, let us discuss about the steps followed by our Support Techs to resolve this error.

1.Firstly cross check the error message by running the docker command again.

2.Next, identify the issue while running the docker command by ec2-user.

As the error says there is permission denied, check out permission of docker files in “/var/run/docker.* ”

ls -la /var/run/docker.*
-rw-r--r-- 1 root root 4 Apr 15 05:05 /var/run/docker.pid
srw-rw---- 1 root docker 0 Apr 15 05:05 /var/run/docker.sock

You can see docker is installed with root user. The sock file has docker group permission.

3.Then, check if ec2-user is there in the docker group by running the below command.

cat /etc/group | grep docker

If you see the result as shown below it means the user is not in the docker group.

docker:x:497:

We need to have the user added to the docker group for the docker commands to run. thus to resolve the error, we need to configure ec2-user in the docker group by using usermod Linux command

sudo usermod -a -G docker ec2-user

4.Next, verify if ec2-user added in the docker group by running the below command.

cat /etc/group | grep docker

docker:x:497:ec2-user

5.Finally, re-login on the same server with ec2-user and check with any docker command.

docker images

 

REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest bb776ce48575 4 days ago 109MB
tomcat latest f1332ae3f570 2 weeks ago 463MB
centos latest 9f38484d220f 4 weeks ago 202MB
amazonlinux latest 01da4f8f9748 6 weeks ago 162MB

 

[Need help with AWS error? We’d be happy to assist]

Conclusion

In short, today we saw the steps followed by our Support Techs to resolve AWS EC2 docker permission denied error.

Are you using Docker based apps?

There are proven ways to get even more out of your Docker containers! Let us help you.

Spend your time in growing business and we will take care of Docker Infrastructure for you.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

2 Comments

  1. peace-keepers.io

    Hello, thanks for the article
    I have ec2-user but i still have the same permission error

    Reply
    • Hiba Razak

      Hi,

      Our Experts can help you with the issue, we’ll be happy to talk to you on chat (click on the icon at right-bottom).

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.