What is Docker?

Yolo Docker guide

An oversimplified explanation of Docker is that Docker is like a VM. You are able to create images with Dockerfiles that install library or dependencies. Then compile them into containers and they will run the same every time. This is useful say if you only meet twice a week and forgot what you installed on the jetsons. You can just read the Dockerfile to see what the container holds.

The next few guides go over our robotics team Docker setup for Robomasters

Dockerfile overview

official Dockerfile docs

The main commands you should know are RUN and FROM

FROM uses someone else’s docker image that has been prebuilt and is a jumping off point for you to build off of.

RUN think of run as running the command in the container.

Make a file called Dockerfile and paste this example setting up ultralytics for jetson jetpack5:

  FROM ultralytics/ultralytics:latest-jetson-jetpack5

RUN apt-get update && \
    apt-get install sudo -y 

# Install Git
RUN sudo apt-get install -y git

# installing CV dependencies 
RUN pip install \
    crc \
    transforms3d \
    pyserial \
    opencv-python  \
    opencv-contrib-python \
    scipy \
    pyrealsense2
    
  

To build the Dockerfile in the same folder run:

  docker build -t my-image .
  

Then to run the image:

  docker run -it my-image bash
  

The -it flag means running the container in “interactive mode” so you are able to do things in the container

If you run pip freeze you should see all the pip dependencies installed

To exit press Ctrl+D

The next few guides go over more settings for Docker such as passing though USB, cameras (realsense), folders, and windows.