Skip to content

Get Started with YOLOv5 🚀 in Docker

This tutorial will guide you through the process of setting up and running YOLOv5 in a Docker container.

You can also explore other quickstart options for YOLOv5, such as our Colab Notebook Open In Colab Open In Kaggle, GCP Deep Learning VM, and Amazon AWS. Updated: 21 April 2023.


  1. Nvidia Driver: Version 455.23 or higher. Download from Nvidia's website.
  2. Nvidia-Docker: Allows Docker to interact with your local GPU. Installation instructions are available on the Nvidia-Docker GitHub repository.
  3. Docker Engine - CE: Version 19.03 or higher. Download and installation instructions can be found on the Docker website.

Step 1: Pull the YOLOv5 Docker Image

The Ultralytics YOLOv5 DockerHub repository is available at Docker Autobuild ensures that the ultralytics/yolov5:latest image is always in sync with the most recent repository commit. To pull the latest image, run the following command:

sudo docker pull ultralytics/yolov5:latest

Step 2: Run the Docker Container

Basic container:

Run an interactive instance of the YOLOv5 Docker image (called a "container") using the -it flag:

sudo docker run --ipc=host -it ultralytics/yolov5:latest

Container with local file access:

To run a container with access to local files (e.g., COCO training data in /datasets), use the -v flag:

sudo docker run --ipc=host -it -v "$(pwd)"/datasets:/usr/src/datasets ultralytics/yolov5:latest

Container with GPU access:

To run a container with GPU access, use the --gpus all flag:

sudo docker run --ipc=host -it --gpus all ultralytics/yolov5:latest

Step 3: Use YOLOv5 🚀 within the Docker Container

Now you can train, test, detect, and export YOLOv5 models within the running Docker container:

python  # train a model
python --weights  # validate a model for Precision, Recall, and mAP
python --weights --source path/to/images  # run inference on images and videos
python --weights --include onnx coreml tflite  # export models to other formats

Created 2023-04-21, Updated 2023-05-09
Authors: Glenn Jocher (3)