How to (su) switch user on amazonlinux docker image?

0

Issue

I am trying to secure amazonlinux docker image.

I know I can use docker USER command.

But the thing is when developing I would like to login to image and su switch user in order to try out how image will work but there is no su command in amazonlinux.

How to logon to docker image and change user using bash commands ?

Solution

One option is to attach directly to the container at run-time or when it’s already running as root or another user with:

docker run -it -u root IMAGENAME bin/bash

or when already running:

docker exec -it -u root CONTAINERNAME bin/bash

Answered By – clarj

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More