3

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!

Foudel
  • 267
  • 3
  • 6
  • 13
  • there is no need to do it this way, docker already has a keyword USER in the Dockerfile https://docs.docker.com/engine/reference/builder/#user – Shailyn Ortiz Dec 26 '18 at 22:52

1 Answers1

2

Your useradd command is wrong as you are creating an user named 123. The last argument of the command is the username so you should use remote_user instead.

codestation
  • 2,938
  • 1
  • 22
  • 22