# custom miniconda build that contains only libraries that we really need
# we can specify for example numpy, pandas, matplotlib ...
# maintainer: tcoil.info
#
# build as
# sudo docker build -t custom_miniconda .
#
# run this image as
# coil@coil:~/Desktop/miniconda_docker_build$ sudo docker run --name custom_miniconda -i -t -p 8888:8888 -v "${PWD}:/notebooks" custom_miniconda
# or with docker compose demonized
FROM centos:8
RUN yum update -y
RUN yum install -y wget
RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
# install in batch (silent) mode, does not edit PATH or .bashrc or .bash_profile
# -p path
# -f force
RUN bash Miniconda3-latest-Linux-x86_64.sh -b
ENV PATH=/root/miniconda3/bin:${PATH}
#RUN source /root/.bashrc
#RUN source /root/.bash_profile
RUN conda update -y conda
RUN conda list
RUN conda install -y numpy \
matplotlib \
pandas
RUN conda install -y jupyter notebook
# create directory for notebooks
RUN mkdir /notebooks
# cleanup
RUN rm Miniconda3-latest-Linux-x86_64.sh
EXPOSE 8888
# start the jupyter notebook in server mode
CMD ["jupyter","notebook","--ip=0.0.0.0","--port=8888","--no-browser","--allow-root", "--notebook-dir=/notebooks"]
Then build and tag the image like this:
coil@coil:~/Desktop/miniconda_docker_build$ sudo docker build -t custom_miniconda .
Run the image and mount local directory to the directory in container where notebooks are stored:
coil@coil:~/Desktop/miniconda_docker_build$ sudo docker run --name custom_miniconda -i -t -p 8888:8888 -v "${PWD}:/notebooks" custom_miniconda
Access the jupyter notebook via web browser via
http://127.0.0.1:8888/
in the shell that runs the container you will see notebook access token. It will look something like this:
[I 20:59:31.233 NotebookApp] or http://127.0.0.1:8888/?token=8da8a424ahfhgfdlkqagdyqqpdhrybsgteowparyttwmnqb47234823nsfndsmsbdfsajd9234c
[I 20:59:31.233 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 20:59:31.238 NotebookApp]
Sources: