Using Anaconda with Docker

Install Docker and add user

[email protected]:~$ sudo apt install docker-compose -y
[email protected]:~$ sudo usermod -aG docker $USER

Create the folder structure

[email protected]:~/anaconda3_docker$ tree
├── data
├── docker-compose.yml
├── Dockerfile
├── notebooks
└── requirements.txt

The data folder will contain input and output data for the notebooks. The notebooks folder will contain the Jupyter notebooks. The Dockerfile will create the folders in the container and install the Python requirements from the requirements.txt.

Content of Dockerfile:

FROM continuumio/anaconda3
ADD requirements.txt /
RUN pip install -r requirements.txt
CMD ["/opt/conda/bin/jupyter", "notebook", "--notebook-dir=/opt/notebooks", "--ip='*'", "--no-browser", "--allow-root"]

Content of docker-compose.yml:

version: '2'
    build: .
      - ./notebooks:/opt/notebooks
      - "8888:8888"

Start the container

[email protected]:~/anaconda3_docker$ docker-compose up --build


Go to your IP-address on the given port and start coding.

My final notebook setup can be found on my Github.