Docker

Configuring Conda in Docker

Anaconda, commonly known as Conda, is a free and open-source package management and virtual environment management system for Python ecosystem.

Using Conda, we can create, manage, and switch between isolated environments containing different versions of Python and packages. You will often find it in the world of data science and statistical computing for its ability to manage the dependencies. It also provides a simplistic way to install and distribute the code.

In this tutorial, we will learn how to install and run the Conda environment in a Docker container using the official Anaconda distributions.

Docker is a free and open-source platform where we as developers can build, ship, and run the distributed applications in nearly any environment.

Download the Anaconda Image

Before running the Conda environment, we can start by searching for the image using the following command:

$ sudo docker search continuumio

Once you locate the image that you wish to download, run the following command to download the image:

$ sudo docker pull continuumio/anaconda3

Once downloaded, run the following command to start a new container using the image:

root@docker-aws:~# docker run -t -i continuumio/anaconda3 /bin/bash

The command should create a new container using the “anaconda3” image and drop you into a new shell.

(base) root@4d7d6fb88d56:/#

This gives you a direct access to the container where the Conda tool is already available.

Finally, you can test the container by running the following command:

$ conda info

To install and launch the Jupyter Notebook, execute the following command from the host machine:

docker run -i -t -p 8888:8888 continuumio/anaconda3 /bin/bash \
-c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir \
/opt/notebooks && /opt/conda/bin/jupyter notebook \
--notebook-dir=/opt/notebooks --ip='*' --port=8888 \
--no-browser --allow-root"

To access the Jupyter Notebook, open http://localhost:8888 in your browser or open http://<DOCKER-MACHINE-IP>:8888 if you are using a Docker Machine VM.

Conclusion

In this tutorial, we learned how to quickly configure the Anaconda environment in a Docker container using the Docker Anaconda3 image.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list