25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

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 *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF