Root access using ubuntu base image

I built a simple docker image which based on a ubuntu image. When doing a docker exec … it doesn’t ask for a root password. What I want is before I can go inside the container it will ask for the root password. i am pretty sure it’s not included on my Dockerfile. Is that possible to have root password upon doing docker exec -it xxx bash

No! you should install the openssh-server package to be able to use ssh with a password. Check this useful document How to setup an ssh server within a docker container - DEV Community

1 Like

YAY! thanks much! Been trying different ways like adding “USER docker” from the docker file, this works and don’t go straight to root prompt, however when specifying docker exec -it -u root name bash, then still goes to root!

OK, again thanks for the link doc, I followed it and was able to ssh to my container. This makes sense as the admin of the docker host most probably won’t allow to have someone to play around with the other containers.