I took the semaphore docker image and via docker file I installed an ssh server. Now I’m faced with a problem:
FROM semaphoreui/semaphore:latest
USER root
RUN apk update &&
apk add --no-cache openssh openrc
RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config &&
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config &&
echo "semaphore:password" | chpasswd
RUN mkdir -p /var/run/sshd
RUN cd /etc/ssh && ssh-keygen -A
EXPOSE 22
USER semaphore
I make the image.
docker build . -t semaphore:ssh
When I launch the container I have to start the ssh server as root user, but I want the container to be started with semaphore user, so I am forced to launch the conatiner as a normal user but then to give an additional command via docker exec which starts the ssh server :
docker run --name semaphore_instance -d semaphore:ssh
docker exec -u0 semaphore_instance /usr/sbin/sshd -D &
Is there a way to avoid this and launching the service with no root user?
Salvatore Esposito is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2