Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Docker to run JupyterLab in a reproducible Python environment, work with notebooks in your project folder, and keep files when a container is removed. Start with docker run; then put the image and run settings in Compose so the setup is easier to repeat.

How Docker fits a data-science workflow

A Dockerfile describes how to build an image, which contains the base software and dependencies for an environment. A container is a running instance of that image. Docker’s JupyterLab guide walks through running a notebook server, customizing its image, and recording its configuration.

For notebook work, keep the distinction between the environment and your work clear: dependencies belong in the image, while notebooks and datasets should be stored in a mounted directory or volume rather than only in a container’s writable layer.

Run JupyterLab in a container

Docker’s local tutorial uses the quay.io/jupyter/base-notebook image, maps host port 8889 to container port 8888, and opens JupyterLab at localhost:8889/lab. A basic launch looks like this:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
docker run -p 8889:8888 quay.io/jupyter/base-notebook

Open http://localhost:8889/lab in your browser. The Jupyter image may print an access URL with a token in the container logs; use the URL provided for your own running instance. Docker’s guide includes a sample token in its tutorial command, but that value is not a credential to reuse. This is a local learning example, not a complete security setup for a server exposed to other people or the internet.

Use existing notebooks and keep them on your computer

Without a mount, files saved only inside a container can be lost when that container is removed. A bind mount connects a directory on your computer to a directory in the container. It is a practical default when you want notebooks to remain in your project folder and be accessible to your normal editor and version-control tools.

From the project directory, mount the current folder at the Jupyter user’s work directory:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
docker run -p 8889:8888 -v "$PWD":/home/jovyan/work quay.io/jupyter/base-notebook

This shell form uses $PWD; the exact host-path syntax varies by operating system and shell. Docker’s JupyterLab guide provides platform-specific command variants. After opening JupyterLab, use the work directory to access the mounted project files. Changes saved there are made to the host folder.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bind mount or named volume?

Storage choice Host visibility After container removal Host-path dependence
Bind mount Files are directly in the host directory you mount. Files remain in that host directory. Uses a host path; Docker notes bind mounts depend on the host’s directory structure and operating system.
Named volume Managed by Docker rather than presented as an ordinary project directory by default. Persists independently of the container unless explicitly removed. Docker manages the storage location.

Docker’s storage documentation explains the distinction between bind mounts and volumes. For an active project that you edit on the host, prefer a bind mount. Choose a named volume when you want Docker-managed persistence without tying storage to a particular host directory.

To use a named volume for Jupyter’s work directory, Docker’s guide demonstrates:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
docker run -p 8889:8888 -v jupyter-data:/home/jovyan/work quay.io/jupyter/base-notebook

Docker creates and manages the jupyter-data volume. Removing the container does not by itself remove this volume, so it can be reused by a later container.

Put Python dependencies in a custom image

Installing packages interactively in a running notebook can make an environment difficult to reproduce. Instead, add required packages to a Dockerfile so each container made from the image starts with those dependencies already installed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create a file named Dockerfile in the project directory:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
FROM quay.io/jupyter/base-notebook
RUN pip install --no-cache-dir matplotlib scikit-learn

Build the image from that directory:

docker build -t my-jupyter-image .

Then launch it with the same port mapping and, if you want the notebooks in your project folder, the bind mount:

docker run -p 8889:8888 -v "$PWD":/home/jovyan/work my-jupyter-image

The packages in this example are installed while building the image, rather than being reinstalled in every new container. Add your project’s other required packages to the build instructions as needed.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Make the setup repeatable with Compose

A docker run command is convenient for a first launch, but its ports, mounts, image build, and startup command are easy to forget or mistype. Compose keeps those settings together in a YAML file. Docker Docs puts the distinction this way: “A Dockerfile provides instructions to build a container image while a Compose file defines your running containers.” The current recommended Compose format is the Compose Specification; a version declaration from older Compose file formats is not required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Save the following as compose.yaml beside the Dockerfile:

services:
  notebook:
    build: .
    ports:
      - "8889:8888"
    volumes:
      - .:/home/jovyan/work

Start the service from that directory:

docker compose up --build

Compose builds the local image and starts JupyterLab with the declared port and project-directory mount. Visit http://localhost:8889/lab. To stop the foreground service, press Ctrl+C; you can also stop the Compose project with docker compose down.

Compose is useful for one service because it records how to run it. It becomes more useful when an analysis also needs supporting services: Docker’s Python guide extends a Compose setup with PostgreSQL and a persistent named volume.

Clean up without deleting notebook data

Stopping or removing the Compose container is different from deleting a named volume. The command docker compose down -v removes named volumes declared for the project as well as the containers and networks. Use the -v flag only when you intend to delete persisted volume data. A project bind mount points to files in your host directory, so removing the container does not remove those host files.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.