10 Using Containers as your Development Space
A very powerful and approachable way to use containers for science is to just use them to develop from.
In previous chapters we discussed how to attach volumes. So you know how you can access your files from a container. But perhaps you don’t want to work completely from command line and would like a Integrated Development Environment (IDE) to work from.
If you use RStudio or Jupyter notebooks, you will really like this chapter.
Docker has a port
option that allows you to work from the container with an IDE if the image you are using has it installed.
Here’s an example of RStudio running from a container and being seen from a Docker port:
Here’s an example of Jupyter running from a container and being seen from a Docker port:
If this is of interest to you, we’ll walk you through how to do this in this chapter!
10.1 Activity Instructions
10.1.1 Jupyter analysis IDE example:
Navigate to the folder that you would like to work in.
Use this command:
docker run --rm -v $PWD:/home/jovyan/work -e JUPYTER_ENABLE_LAB=yes -p 8888:8888 jhudsl/reproducible-python
Copy and paste the output URL to your favorite browser.
Develop to your heart’s content as you normally would with Jupyter notebooks.
If you need packages that aren’t here, now you know how to take the Dockerfile and modify it. Here’s the dockerfile and associated GitHub repo for this image.
10.1.2 RStudio analysis IDE example:
Navigate to the folder that you would like to work in.
Use this command but replace the password
part with your own password.
docker run -it -v $PWD:/home/rstudio -e PASSWORD=password -p 8787:8787 jhudsl/reproducible-r
Then copy and paste localhost:8787
in your internet browser.
On this page, your username will be rstudio
and your password will be whatever you specified.
Develop to your heart’s content in this RStudio IDE normally would.
If you need packages that aren’t here, now you know how to take the Dockerfile and modify it. Here’s the dockerfile and associated GitHub repo for this image.