(1): I don't know, but that does not matter. If you run docker run -it centos
you start a new container and are inside it immediately as root. You could set then interactively a new root password with passwd
. But this is a rare usecase, mostly used for first steps into containers.
(2): If someone derives from a base image, try to get the Dockerfile
for that. That way you can look up if and which password he set. If that Dockerfile
is not available I'd personally question that quality of the image at large, since you never know what else might be baked into the image. Your milage may vary. In any case, you could derive in turn from that image and set yet another root password.
(3): Your proposed way with passwd
is fair enough, but implementing a fixed password into a container feels wrong for me anyway. A container should implement one task and effectively never need to be logged into. For exceptional troubleshooting sessions, you can always access the container from the Docker host with "docker attach" or "docker exec". If you really need to log into the container, place a ssh public key into a ~/.ssh/authorized_keys
, so you can control from the outside who gets access to the container (whoever has access to the corresponding secret ssh key).
What are you hoping to put onto the CentOS image? I'm curious about the full context of this question since I may need to provide more context to my answer to give you what you really need in addition to what you asked for. – Stuporman – 2015-09-29T04:42:14.100