Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/bin/sh: 1: cannot create /etc/passwd: Permission denied when running nvidia-docker build -t tano297/bonnetal:runtime -f Dockerfile . #12

Open
pedrombmachado opened this issue Nov 26, 2019 · 1 comment

Comments

@pedrombmachado
Copy link

pedrombmachado commented Nov 26, 2019

Dear maintainers,
I am getting the following error when running nvidia-docker build -t tano297/bonnetal:runtime -f Dockerfile .

---> Running in 8399ad0e2141
/bin/sh: 1: cannot create /etc/passwd: Permission denied
The command '/bin/sh -c export uid=1000 gid=1000 && mkdir -p /home/developer && mkdir -p /etc/sudoers.d && echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && echo "developer:x:${uid}:" >> /etc/group && echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && chmod 0440 /etc/sudoers.d/developer && chown ${uid}:${gid} -R /home/developer && adduser developer sudo' returned a non-zero code: 2

@sequoia-hope
Copy link

sequoia-hope commented Apr 29, 2020

I was just affected by this bug. I got it to work by adding sudo in a few places. Here is the modified Dockerfile:

FROM tano297/bonnetal:base

# who am I
MAINTAINER Andres Milioto <amilioto@uni-bonn.de>

CMD ["bash"]

# to use nvidia driver from within
LABEL com.nvidia.volumes.needed="nvidia_driver"

# this is to be able to use graphics from the container
# Replace 1000 with your user / group id (if needed)
RUN export uid=1000 gid=1000 && \
  mkdir -p /home/developer && \
  mkdir -p /etc/sudoers.d && \
  echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" | sudo tee -a /etc/passwd && \
  echo "developer:x:${uid}:" | sudo tee -a /etc/group && \
  echo "developer ALL=(ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers.d/developer && \
  sudo chmod 0440 /etc/sudoers.d/developer && \
  sudo chown ${uid}:${gid} -R /home/developer && \
  sudo adduser developer sudo

# Set the working directory to $HOME/bonnetal
ENV HOME /home/developer
WORKDIR $HOME/bonnetal

# Copy the current directory contents into the container at $HOME/bonnetal
ADD ./ $HOME/bonnetal

# ownership of directory
RUN sudo chown -R developer:developer $HOME/bonnetal
RUN sudo chmod 755 $HOME/bonnetal

# user stuff (and env variables)
USER developer
RUN cp /etc/skel/.bashrc $HOME/ && \
  echo 'source /opt/ros/melodic/setup.bash' >> $HOME/.bashrc && \
  echo 'source $HOME/bonnetal/deploy/devel/setup.bash' >> $HOME/.bashrc && \
  echo 'export PYTHONPATH=/usr/local/lib/python3.5/dist-packages/cv2/:$PYTHONPATH' >> $HOME/.bashrc && \
  echo 'export NO_AT_BRIDGE=1' >> $HOME/.bashrc

ENTRYPOINT ["/bin/bash","-c"]

# for visual output run as:
# nvidia-docker run -ti --rm -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/.Xauthority:/home/developer/.Xauthority -v /home/$USER:/home/$USER --net=host --pid=host --ipc=host tano297/bonnetal:runtime /bin/bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants