Search code examples
rdockerrstudiorstudio-serverreproducible-research

docker for toolkit documentation: `docker export` not including all layers?


After having given up on other means to document my R analysis environment(s) properely with the aim of analysis reproducibility, I'm setting out, to wrap each individual analysis into a docker container. Here is what I do:

  1. Pull the latest rstudio container from the rocker project:

    docker pull rocker/rstudio
    
  2. Create a project-specific copy

    docker run -d -p 8787:8787 rocker/rstudio # Produces baseID
    docker commit --message="Snapshot of current rocker/rstudio container" <baseID> rstudio_project.2018
    docker stop <baseID>
    
  3. Fire up the container:

    docker run -d -p 8787:8787 -e ROOT=TRUE rstudio_project.2018 # produces ID
    
  4. R(Studio)- based project analysis ... finishing with sudo apt-get clean and sudo rm -rf /tmp/*

  5. Export a docker image:

    docker export -o docker_rstudio_project.2018.tar <ID>
    xz docker_rstudio_project.2018.tar
    

After having deleted all related containers/images from my local registry, I try to emulate the revisit of the packaged project like so:

  1. Import the container:

    docker import docker_rstudio_project.2018.tar.xz rstudio_project.2018.2
    
  2. (Try to) Fire up container as was done for the original:

    docker run -d -p 8787:8787 -e ROOT=TRUE rstudio_project.2018.2

I am then faced with the following error:

docker: Error response from daemon: No command specified.

What am I doing wrong? Where did the container loose (what) information on what to start by default?


Solution

  • The export and import commands only handle the file system, not metadata like what command to run. Use save and load instead. See also https://github.com/moby/moby/issues/1826