Dockerfile,带有GUI参数的groupadd

时间:2018-11-25 22:11:15

标签: docker ubuntu dockerfile

我试图添加具有在dockerfile中声明的ID的组,但是我总是收到错误消息:

async

我的dockerfile:

groups: cannot find name for group ID 1001 

当我尝试使用以下方式输入容器时收到错误消息:

FROM python:3.7.1
ARG UID=1001
RUN apt-get update && apt-get install -y openssh-server sudo
RUN mkdir /var/run/sshd
RUN echo 'root:pycharm' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
RUN groupadd -r charm -g 1001
RUN useradd -ms /bin/bash charm -g charm -u 1001
RUN echo "export VISIBLE=now" >> /etc/profile
ADD helpers /opt/.pycharm_helpers
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]

docker exec -ti -u 1001 pydebug1 bash 文件中不存在组。当我在容器内运行命令时可以正常工作,但我希望将其包含在Dockerfile中。

1 个答案:

答案 0 :(得分:0)

将您的dockerfile内容保存在Dockerfile中,并触摸了名称为helpers的文件。

然后构建图像并输入图像。屏幕快照显示了第二个构建,提交哈希等以及图像中的id。您可以在屏幕快照中看到所有命令。

enter image description here

您也可以以docker build -t pydebug1 .的身份进行构建。