Docker中的非root用户 [英] Non-root user in Docker
本文介绍了Docker中的非root用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个基本的Dockerfile:
I have a basic Dockerfile:
FROM ubuntu:xenial
USER test
ENTRYPOINT ["/bin/bash"]
对于此Dockerfile,我希望能够创建一个没有密码,并且在运行Docker容器时,我希望使用该用户,而不是root用户。当我尝试运行容器时, docker run -it test:1
时,出现此错误:
For this Dockerfile, I want to be able to create a user without a password, and when the Docker container is run, I want that user to be used, instead of root. When I try to run the container, docker run -it test:1
, I get this error:
docker: Error response from daemon: linux spec user: unable to find user test: no matching entries in passwd file.
我如何在Dockerfile中创建用户,并在容器为容器时将该用户作为默认用户
How can I create a user in a Dockerfile and have that user be the default user when the container is run interactively?
推荐答案
添加 RUN useradd -s / bin / bash用户
在 USER 指令之前。
这篇关于Docker中的非root用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文