Can someone help me sort the below issue out? I am trying to spin up an ubuntu image with the below Dockerfile
FROM ubuntu:16.04
RUN apt-get -q -y update && \
apt-get -q -y upgrade && \
apt-get -q -y install ssh
RUN groupadd remote_user
RUN useradd -d /home/remote_user -ms /bin/bash -g remote_user -G remote_user -p 123 123 && \
mkdir /home/remote_user/.ssh && \
chmod 700 /home/remote_user/.ssh
RUN ls
COPY remote-key.pub /home/remote_user/.ssh/authorized_kyes
RUN ls /home/
RUN chown -R remote_user:remote_user /home/remote_user/.ssh/ && \
chmod 600 /home/remote_user/.ssh/authorized_keys
RUN /usr/sbin/sshd-keygen
CMD /usr/sbin/sshd -D
When building using docker-compose build
, I am getting invalid user: remote_user:remote_user
See the some of the output of the build:
Step 8/10 : RUN chown -R remote_user:remote_user /home/remote_user/.ssh/ &&
chmod 600 /home/remote_user/.ssh/authorized_keys
---> Running in 7c161db2565e
chown: invalid user: 'remote_user:remote_user'
ERROR: Service 'remote_host' failed to build: The command '/bin/sh -c chown -R remote_user:remote_user /home/remote_user/.ssh/ && chmod 600 /home/remote_user/.ssh/authorized_keys' returned a non-zero code: 1
Thanks in advances!
答案 0 :(得分:1)
在创建名为useradd
的用户时,您的123
命令是错误的。该命令的最后一个参数是用户名,因此您应该使用remote_user
。