0

Issue

When following the AWS guide for installing Docker (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html), I'm stuck on step 8 docker info. Permission should have been added in step 6 so that ec2-user can run this without sudo, but it can't.

Error

$ docker info

-bash: /usr/bin/docker: Permission denied

Troubleshooting

I have restarted the instance, logged out and in, and stopped and started docker.

id ec2-user returns uid=1000(ec2-user) gid=1000(ec2-user) groups=1000(ec2-user),4(adm),10(wheel),190(systemd-journal),992(docker)

I've installed docker-compose and tried to change permissions in other ways:

  • sudo usermod -a -G sudo ec2-user
  • sudo setfacl -R -m user:ec2-user:rw /usr/bin/docker

Desired Behaviour

I'd like the permissions to be fixed, whether that means reinstalling Docker or just amending permissions.

Jules
  • 303
  • 2
  • 13

1 Answers1

0

If you want to avoid typing sudo whenever you run the docker command, add your username to the docker group:

sudo usermod -aG docker $(whoami)

You will need to log out of the Droplet and back in as the same user to enable this change.

If you need to add a user to the docker group that you’re not logged in as, declare that username explicitly using:

sudo usermod -aG docker username
ariefs
  • 569
  • 1
  • 4
  • 16
  • Thanks for your response. That was step 6 that I mentioned in the guide, I've just run it again to be sure. – Jules Jun 24 '21 at 10:59
  • Remember that the ability to run any `docker` command implies the ability to root the host. On a production-oriented (cloud-hosted) system it's not unreasonable to require `sudo` permissions to run `docker`. – David Maze Jun 24 '21 at 11:49
  • The AWS docs are explicit that it can be done simply. I would be less concerned but my CI runs Docker commands, and I have no reason to believe that it shouldn't be possible. – Jules Jun 24 '21 at 11:59