Using foyer with Docker¶
As much of scientific software development happens in unix platforms, to avoid the quirks of development dependent on system you use, a recommended way is to use docker or other containerization technologies. This section is a how to guide on using foyer with docker.
A docker installation in your machine. Follow this link to get a docker installation working on your machine. If you are not familiar with docker and want to get started with docker, the Internet is full of good tutorials like the ones here and here.
After you have a working docker installation, please use the following command to use run a jupyter-notebook with all the dependencies for foyer installed:
$ docker pull mosdef/foyer:latest $ docker run -it --name foyer -p 8888:8888 mosdef/foyer:latest su anaconda -s\ /bin/sh -l -c "jupyter-notebook --no-browser --ip="0.0.0.0" --notebook-dir\ /home/anaconda/foyer-notebooks"
If every thing happens correctly, you should a be able to start a jupyter-notebook server running in a python environment with all the dependencies for foyer installed.
Alternatively, you can also start a Bourne shell to use python from the container’s terminal:
$ docker run -it --name foyer mosdef/foyer:latest
The instructions above will start a docker container but containers by nature are ephemeral, so any filesystem changes (like adding a new notebook) you make will only persist till the end of the container’s lifecycle. If the container is removed, any changes or code additions will not persist.
Persisting User Volumes¶
If you will be using foyer from a docker container, a recommended way is to mount what are called user volumes in the container. User volumes will provide a way to persist all filesystem/code additions made to a container regardless of the container lifecycle. For example, you might want to create a directory called foyer-notebooks in your local system, which will store all your foyer notebooks/code. In order to make that accessible to the container(where the notebooks will be created/edited), use the following steps:
Create a directory in your filesystem
$ mkdir -p /path/to/foyer-notebooks $ cd /path/to/foyer-notebooks
Define an entry-point script. Inside foyer-notebooks in your local file system create a file called
dir_entrypoint.shand paste the following content.
#!/bin/sh chown -R anaconda:anaconda /home/anaconda/foyer-notebooks su anaconda -s /bin/sh -l -c "jupyter-notebook --no-browser --ip="0.0.0.0" --notebook-dir /home/anaconda/foyer-notebooks"
Run docker image for foyer
$ docker run -it --name foyer -p 8888:8888 --entrypoint /home/anaconda/foyer-notebooks/dir_entrypoint.sh -v $HOME/foyer-notebooks:/home/anaconda/foyer-notebooks mosdef/foyer:latest
You can remove the created container by using the following command:
$ docker container rm foyer
Instead of using latest, you can use the image
mosdef/foyer:stable for most recent stable release of foyer and run the tutorials.