I have an issue while running docker container as non-root user. My DockerFile is
.....ARG SSH_KEY
RUN mkdir root/.ssh/ &&\
chmod 0700 /root/.ssh/ &&\
ssh-keyscan -t (url) >> root/.ssh/known_hosts &&\
echo "{SSH_KEY}" > /root/.ssh/id_rsa &&\
chmod 600 ~/.ssh/id_rsa
COPY host_config root/.ssh/config
ADD ./entrypoint.sh /apps/entrypoint.sh
RUN chmod -R 755 /apps/
ENTRYPOINT "./apps/entrypoint.sh"
entrypoint.sh file contains git commands
git clone ssh://repository.com
Docker-compose file
user: 5555:5555
host_config file
Host *
IdentityFile /root/.ssh/id_rsa
StrictHostKeyChecking no
UserKnownHostsFile
When I use user option in docker-compose file it gives an error "fatal:could not create work tree dir repository name Permission denied", but when I run docker container with root user it works.
When I create new directory "example" in DOCKERFILE and add do chown that non-root user to that "example" folder then try git clone in that folder it gives an error "Host key verification failed".
Is there any way of running docker container that has script file with git commands with non-root user?