Docker Community Forums

Share and learn in the Docker community.

Adding user to docker container and give them access to host folder

build

(Mictadlo) #1

I am able only to give the first user write, executable and read access to the export folder in the below Dockerfile

FROM ubuntu:14.04.4

MAINTAINER Mic

RUN echo "deb cran.csiro.au/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 \
&& apt-get update -y \
&& apt-get upgrade -y

ENV R_BASE_VERSION 3.2.4
ENV BIOC_VERSION 3.2

# R Setup
RUN apt-get install -y 	r-base=${R_BASE_VERSION}* \
			    r-base-dev=${R_BASE_VERSION}* \
		    r-recommended=${R_BASE_VERSION}* \
		    r-cran-littler \
		    gdebi-core \
		    libxml2-dev \
		    libcurl4-openssl-dev \
		    wget


# Rstudio Setup

RUN VER=$(wget --no-check-certificate -qO- https://s3.amazonaws.com/rstudio-server/current.ver) \ 
&& wget -q download2.rstudio.org/rstudio-server-${VER}-amd64.deb \ 
&& gdebi -n rstudio-server-${VER}-amd64.deb \ 
&& rm rstudio-server-${VER}-amd64.deb 



## Use s6
RUN wget -P /tmp/ https://github.com/just-containers/s6-overlay/releases/download/v1.11.0.1/s6-overlay-amd64.tar.gz \
  && tar xzf /tmp/s6-overlay-amd64.tar.gz -C /

COPY userconf.sh /etc/cont-init.d/conf
COPY run.sh /etc/services.d/rstudio/run


COPY add-students.sh /usr/local/bin/add-students    


# Mark folders as imported from the host.
VOLUME ["/export/"]    

RUN groupadd galaxy \
&& chgrp -R galaxy /export \
&& chmod -R 770 /export

## Set a default user. Available via runtime flag `--user docker` 
## Add user to 'staff' group, granting them write privileges to /usr/local/lib/R/site.library
## User should also have & own a home directory (for rstudio or linked volumes to work properly). 
RUN useradd dudleyk \
    && mkdir /home/dudleyk \
    && chown dudleyk:dudleyk /home/dudleyk \
    && addgroup dudleyk galaxy \	
    && ln -s /export/ /home/dudleyk/ \
    && echo "dudleyk:dudleyk" | chpasswd 

RUN useradd lorencm \
    && mkdir /home/lorencm \
    && chown lorencm:lorencm /home/lorencm \
    && addgroup lorencm galaxy \
    && ln -s /export/ /home/lorencm/ \
    && echo "lorencm:lorencm" | chpasswd 

EXPOSE 8787

CMD ["/init"]

I logged to the docker container with docker run -it -v /home/galaxy:/export rstudio bash and it showed me the following

ls -ahl
drwxr-xr-x  43 dudleyk galaxy 4.0K Apr  8 00:09 export

How do I give the second user write, executable and read access to the export?

Thank you in advance