Jupyter Notebook on container
GUI container on the *Docker*
- Launch a container on docker in GUI mode
- Run any GUI software on the container
We are going to launch jupyter notebook on container
Step 1: Create Dockerfile
To launch jupyter notebook we first need to install
- python
- jupyter
- firefox or any other browser as jupyter notebook uses browser
In Dockerfile , first we have base image as centos
Then download python3, jupyter and firefox
Expose ports 8888,80,8080 (8888 for jupyter notebook, 80 & 8080 for firefox)
All above commands are run at build time i.e while building the images
jupyter notebook command will run at run time i.e whenever we launch container using the image
Note: Remember to name file as Dockerfile
You can find the dockerfile at link below
Step 2: Build image from dockerfile
Go to path where you have create dockerfile
Build image using docker build -t jupyterimage:v1 .
where -t used for tag as we have given jupyterimage:v1 as tag
Don’t forget dot(.) at last it tells to use current path
Step 3: Launch container using the image
Launch container using docker run -it --net=host -e DISPLAY imageName
Here , -e DISPLAY is for telling to use display for host , giving --net=host option to the docker create or docker run commands, Docker uses the host’s network stack for the container. The network configuration of the container is the same as that of the host and the container shares the service ports that are available to the host. This configuration does not provide any network isolation for a container.
As soon as we launch the container we can see jupyter notebook open in browser of centos i.e of container, it is using display of host to show browser
Hence, we can similarly launch other GUI software in containers as well