Docker Community Forums

Share and learn in the Docker community.

Change the root password

Hi All
Is it possible to change the root user password in Docker?
I have the following lines in my alpine docker:

RUN echo “root:Dev123” | chpasswd
RUN adduser appuser -D

USER appuser

by which I expect the followings:

  1. Change the root user password
  2. Add a new user to the docker, “appuser”
  3. Start the docker container with the “appuser”

Steps 2 & 3 go find and I can see that the docker is started with the “appuser” user but it is also possible to run the docker container as “root” like below

docker container run -it --user root myimg:latest sh

without being asked for the root password and by that I assume that it is either not possible to change the password or the docker core somehow knows the new password.

Hope someone knows how to set the password for root.

Bests
Ramin