【发布时间】:2020-03-28 12:11:51
【问题描述】:
我尝试执行 Docker-compose 构建但收到以下错误。
我正在使用 centos7 并且对 Linux 完全陌生。
/bin/sh: passwd: command not found.
ERROR: Service 'remote_host' failed to build: The command '/bin/sh -c useradd remote_user && echo "welcome1" | passwd remote_user --stdin && mkdir /home/remote_user/.ssh && chmod 700 /home/remote_user/.ssh' returned a non-zero code: 127.
DockerFile.
FROM centos: latest
RUN yum -y install OpenSSH-server
RUN useradd remote_user && \
echo "welcome1" | passwd remote_user --stdin && \
mkdir /home/remote_user/.ssh && \
chmod 700 /home/remote_user/.ssh`enter code here`
COPY remote-key.pub /home/remote_user/.ssh/authorized_keys
RUN chown remote_user:remote_user -R /home/remote_user chmod 600 /home/remote_user/.ssh/authorized_keys
RUN /usr/sbin/sshd-keygen
CMD /usr/sbin/sshd -D
whoami: mosses987 $PATH:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/mosses987/.local/bin:/home/mosses987/bin
【问题讨论】:
-
没有预装。如果您运行
docker container run --rm -it centos,您可以检查/usr/bin(ls -l /usr/bin) 中的内容。 -
sh 存在于 /usr/bin [root@df322206d5a6 bin]# sh sh-4.4#
-
sh是但passwd不是。你的错误是passwd: command not found。 -
它也有密码 [mosses987@localhost bin]$ find -L /bin/ -name "passwd" /bin/passwd
-
您是在容器中搜索还是在本地机器上搜索?
标签: linux docker jenkins docker-compose