1 year ago
#360397
Gaurav Sharma
Why am I getting permission issues while writing a file even after using --user with chmod777?
I have built an image and run that container as --user gauravs
. I used --user gauravs
to build my image, provided all sudo functionalities to the user and modify the permissions to 777, but still, I am getting a permission error whenever I try to write any file (give commands in my script). I need to manually do touch \<file\>
then chmod 777 \<file\>
. May I request you to tell me what I am doing wrong?
What I have found when I run any experiment, ps aux|grep <pid>
shows some random name associated with it, and that random name is later associated with mine.
awoodard 2805117 8778 0.6 27876664 5175500 ? Rsl 10:31 8783:54 python3 main.py --gpu_num 1
gauravs 2808325 0.0 0.0 9032 2708 pts/1 S+ 12:11 0:00 grep --color=auto 2805117
The Dockerfile I used:
FROM nvidia/cuda:11.1-devel-ubuntu20.04
RUN apt-get update
RUN apt-get -y --no-install-recommends install apt-utils
RUN apt-get -y --no-install-recommends install curl ca-certificates
RUN apt-get -y --no-install-recommends install sudo \
git \
bzip2 \
libx11-6 \
wget \
build-essential \
pkg-config \
vim
RUN mkdir /app
WORKDIR /app
VOLUME /app
CMD bash
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
#RUN apt-get -y --no-install-recommends install python3-dev python3-pip
#ENV user gauravs
#RUN adduser --disabled-password --gecos '' --shell /bin/bash ${user} \
# && chown -R ${user}:${user} /app \
# && adduser ${user} sudo
#RUN echo "%sudo ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers
#USER ${user}
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
&& chown -R user:user /app \
&& adduser user sudo
RUN echo "%sudo ALL=(ALL) NOPASSWD:ALL">/etc/sudoers
USER user
#ENV PATH=/home/${user}/.local/bin:$PATH
ENV PATH=/home/user/.local/bin:$PATH
RUN sudo chmod 777 -R /app
#RUN sudo chmod 777 /home/${user}
RUN sudo chmod 777 /home/user
RUN sudo apt-get -y --no-install-recommends install python3-dev
RUN sudo apt-get -y --no-install-recommends install python3-pip
# Install Dependencies
RUN pip3 install --user --upgrade setuptools
RUN pip3 install --user wheel
RUN sudo apt-get -y --no-install-recommends install nvidia-cuda-toolkit
COPY requirements.txt .
RUN pip3 install --user -r requirements.txt
RUN pip3 uninstall -y torch
#RUN pip3 install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
RUN pip3 install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
RUN pip3 install --user torchtext==0.9.0
docker
user-permissions
0 Answers
Your Answer