Root password inside a Docker container

2020-01-30 02:10发布

I'm using a Docker image which was built using the USER command to use a non-root user called dev. Inside a container, I'm "dev", but I want to edit the /etc/hosts file.

So I need to be root. I'm trying the su command, but I'm asked to enter the root password.

What's the default root user's password inside a Docker container?

标签: docker
13条回答
相关推荐>>
2楼-- · 2020-01-30 03:13

I am able to get it working with the below command.

root@gitnew:# docker exec -it --user $(username) $(containername) /bin/bash
查看更多
登录 后发表回答