Docker 容器内的 root 密码 [英] Root password inside a Docker container

查看:109
本文介绍了Docker 容器内的 root 密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个使用 USER 命令构建的 Docker 映像,以使用名为 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆