This repo is part of the introductory workshop on Docker focusing specifically on containerization for data-science applications. This workshop is offered as a part of the Applied Data Science Lab program at Cybera. It contains the setup/config files to build and successfully run a JupyterLab container using Docker. JupyterLab provides a web-based interactive development environment for jupyter notebooks, code, and data. It’s widely used to prototype and develop different data-science applications. To learn more about JupyterLab, visit the link here.
- Introduction
- Installation
- Need for Containerization
- Benefits for Data Science Enthusiasts
- Build Jupyter Lab Container
- Build GPU enabled Jupyter Lab Container
Docker is an open-source platform for developing, shipping, and running applications. It reduces the delay between writing code and deploying it in production.
For starters, the official Docker guide provides a good head start on using Docker.
Docker Compose is a tool that enables running multiple Docker containers. Docker Compose is defined as a YAML file to configure different applications' services.
- Download the installation wizard from Dockerhub.
- It will lead you through all the steps for your operating system. You can also create an online account.
- Once it’s finished installing, open your CLI and enter the following commands to verify if the
Dockeris running successfully:
docker --version
- Please note that if you have installed
Docker Desktopcorrectly using the above steps. Then, theDocker Composecomes pre-installed. If not, please go through this link to install Docker Compose. - To check if
Docker Composeis configured correctly, please run
docker compose --version
- A container is a standard software unit that encapsulates each application with its operating environment.
- Containers package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package.
- The isolation and security allow you to run many containers simultaneously on a given host.
- Automate the boring stuff
- Reproducibility
- Fast, consistent delivery of your applications
- Responsive deployment and scaling
- Running more workloads on the same hardware
- Not having to worry about package dependencies
First, clone this repository on your remote server/virtual machine (vm) or local by using https or ssh or Github CLI.
Then, run the following commands in your terminal to build and deploy the JupyterLab container:
cd docker101_jupyterlab
docker compose up --build
The above step extracts and downloads the specified JupyterLab image onto your VM or local and then spins it onto a running instance called as the container.
Use CTRL + C to exit out of the container at any time.
To run the container in detached mode so that you can reuse the existing terminal, please add -d while building the image as follows
docker compose up --build -d
You could also run
docker compose up -d
This will just reuse the image if it already exists on your VM or local, If not, it will extract again. But --build forces the docker to rebuild the image every time it's run. This is helpful and must when you are adding new requirements to your container.
If you have multiple containers listed on the Docker Compose file and you wish to start only the JupyterLab container, run the above command with the desired Docker service name as follows.
docker compose up -d jupyter101
If you have successfully built and deployed the JupyterLab image container using the above commands, you can access the web interface of the JupyterLab at
http://localhost:8777
You might be prompted to enter the token while accessing the http://localhost:8777. The token can be obtained from the logs of the running JupyterLab container as follows.
docker logs <container-id>
To view the list of all the containers and get the associated container id of the jupyter, run
docker ps -a
Then locate and copy the container id from the displayed list of containers that are built.
If you are able to access and run the Welcome.ipnb notebook, you are all set and have configured JupyterLab correctly.
To stop the running container, run
docker stop <container-id>
To remove the container, run
docker rm -f <container-id>
To cleanup all the old images and associated containers, run
docker system prune -a
Please exercise caution while running the above command as it deletes the old images and stopped containers.
If you are using Microsoft Windows, and are unable to reach your JupterLab container please make sure your firewall is allowing Docker to use your selected port. You may also need to enter the following commands:
net stop winnat
docker start ...
net start winnat
This medium article describes how to set up our own customized GPU-based Jupyter easily using docker. Please use this to configure your GPU instance.
After following the above steps in the article, from the terminal run:
docker compose --profile gpu up -d
If you have successfully built and deployed the GPU JupyterLab image container using the above command, you can access the web interface of the JupyterLab, after relevant port forwarding, at
http://localhost:8778