I’m using the command bellow to execute Anaconda inside a docker container.
But I want to transform it in a Dockerfile so I could just send a docker run to up the application.
The idea is simple: run it locally in port 8888 reading <<my_directory>>.
Don’t need to execute the big command bellow every time.
How could I do that?
docker run -i -t -p 8888:8888 -v <<my_directory>>:/opt/notebooks continuumio/anaconda3 /bin/bash -c "
conda install jupyter -y --quiet &&
mkdir -p /opt/notebooks &&
jupyter notebook
--notebook-dir=/opt/notebooks --ip='*' --port=8888
--no-browser --allow-root"
2
Answers
Have you looked at this: running conda's jupyter on docker
alternatively, you could try something like:
check out this: https://towardsdatascience.com/making-docker-and-conda-play-well-together-eda0ff995e3c
and this the dockerfile and explanation in this: https://github.com/NewportDataProject/data-night
Since you cannot use
volumes
inDockerfile
, I recommend usingdocker-compose
andDockerfile
both.Create a file called
docker-compose.yml
beside yourDockerfile
as the following:Now add these lines to your
Dockerfile
:But if you want to your
bash -c ...
command run and make up your container, then change yourDockerfile
to this:And finally run:
to run in detach mode.
Or run:
to run and see the logs.
This is how you can install
docker-compose
: https://docs.docker.com/compose/install/