I am trying to add the ssh private key to docker building from the Dockerfile, it looks wired that I cannot access it even if it has full permission
Docker Version: 1.0.0
Docker host: ubuntu 14.04
Here Dockerfile
FROM ubuntu:latest
ENV HOME /home/larry
RUN useradd larry && echo 'larry:docker' | chpasswd
RUN echo "larry ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
ADD larry.id_rsa $HOME/.ssh/id_rsa
RUN \
chmod 700 $HOME/.ssh &&\
chmod 600 $HOME/.ssh/id_rsa
RUN chown -R larry:larry $HOME
After I create the image and run in the container and su for the user larry, I got
$ id
uid=1000(larry) gid=1000(larry) groups=1000(larry)
$ ls -al
total 12
drwxr-xr-x 5 larry larry 4096 Jun 21 01:29 .
drwxr-xr-x 5 root root 4096 Jun 21 01:29 ..
drwx------ 2 larry larry 4096 Jun 21 01:29 .ssh
$ cd .ssh
-su: cd: .ssh: Permission denied
Maybe I missed some basic concept in docker? Just plugged in from a typical unix user perspective.
I also added this to github https://github.com/dotcloud/docker/issues/1295#issuecomment-46700769
source
share