Docker容器内的root密码 [英] Root password inside a Docker container
本文介绍了Docker容器内的root密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是Docker映像,该映像是使用USER命令构建的,以使用名为 dev
的非root用户。
在容器中,我是开发人员,但我想编辑 / etc / hosts
文件。
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.
所以我需要成为root。我正在尝试su命令,但要求输入root密码。
So I need to be root. I'm trying the su command, but I'm asked to enter the root password.
Docker容器中默认的root用户密码是什么?
What's the default root user's password inside a Docker container?
推荐答案
最终,我决定重建Docker映像,以便通过一些我知道的方式更改root密码。
Eventually, I decided to rebuild my Docker images, so that I change the root password by something I will know.
RUN echo 'root:Docker!' | chpasswd
或
RUN echo 'Docker!' | passwd --stdin root
这篇关于Docker容器内的root密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文