How to copy files to each user's space in docker
I am writing a docker file to conduct an evaluation of an R package that I have written. The package is installed inside RStudio server. My docker file inherits from
FROM rocker/rstudio. I want the docker file to install the everything (which it does) and create 20 users (user1, user2, …, user20) as test subjects. Each test subject additionally should have a data folder (/home/data) to contain some CSV files.
Later when the container is run, The RStudio’s web interface allows the test subjects to login using the user credentials just created. They have access to their own data, perform the tests, and generates some new files in their home directory.
I am able to create the users using
RUN useradd -ms /bin/bash user1 and set the current user to users
USER user1, but do not know how to transfer the files alongside the Dockerfile.
Note 1: I do not like the dea of putting the files on the host machine and sharing them with the docker users. Instead I want to have them shipped with the Dockerfile and get them added to the image and container when the Dockerfile is built and run.
Note 2: I need to do the evaluation is a reproducible way, because I need to repeat it several times.
One Solution collect form web for “How to copy files to each user's space in docker”
You can use the
ADD command in the dockerfile to get files in to you docker machine. Have a look here for more information.