The standard way : The standard way is to write everything in a DockerFile, build an image using this file and deploy the image. But for someone just starting to learn docker, this is really difficult.
The dumb way : As a beginner its better to one by one install and modify things and commit the changes ourselves. Once someone becomes comfortable with this, they can directly write DockerFile and directly make images with everything setup.
Create a local docker image, modify it, then deploy on a remote machine as a docker container and access jupyter notebook running inside this container.
Save the following in a file named DockerFile
FROM continuumio/miniconda3
RUN conda install jupyter
This pulls an image from dockerhub that has conda install in some linux distribution. Then run following command from same directory:
docker build my_image .
Now our basic image is ready. We run it as a container, inspect it interactively, make some changes and then commit those changes.
- Open the image (run container) in interactive mode : docker run -it my_image /bin/bash
- Now make changes to the image, it can be pulling a git repo or copying some files.
- Change jupyter config file to allow all connections
- Exit the container and commit changes using :
- Save the image file : sudo docker save -o /home/prakhar test_image
- Install docker on remote machine.
- copy image we just created
- copy any data
- Load the copied image to sudo docker load --input test_image
ssh to Remote Machine goto root service docker status/start Create two tmux screens, one for docker, one for host Window 1 :Start Container : docker run -v /path/to/media -it -p 8888:8888 my_image /bin/bash Window 2 : Monitor container
jupyter notebook --ip 0.0.0.0 --allow-root
- Access notebook at ip-of-remote-machine:8888
- Use the tocken printed in terminal to authenticate
- Close jupyter.
- exit container.
- docker commit rwerwe first_image
- docker remove rm image_ID
- service docker stop
- status : service docker status
- save : sudo docker save -o /home/prakhar test_image
- load : sudo docker load --input test_image
- remove all containers : sudo docker rm $(sudo docker ps -a -q)
PS : This gist might be really dumb.... I created this when I was first starting out with docker,