Tutorial 3 - Intro to Docker for Robotics
Learn what ROS 2 is, how workspaces are structured, and how to create your first package.
π― Learning Objectives
- Understand what Docker is and why it's useful in robotics
- Identify key Docker concepts (images, containers, Dockerfiles)
- Learn the benefits of using Docker for reproducibility and isolation
What is Docker?
Imagine your laptop is a kitchen. Docker is like having a bunch of meal kits β everything you need to cook a specific meal (or run a software project) is packed neatly together. No missing ingredients, no mess.
Docker allows you to package an application and all its dependencies into a container. This container can run on any computer with Docker installed, regardless of the operating system.
π Learn more: Docker Overview
Why Use Docker in Robotics?
- β Reproducibility: Everyone on your team runs the same setup.
- β Isolation: No conflicts between projects.
- β Portability: Move between laptops, labs, or robots with no reinstallation.
Core Docker Concepts (with Visual Aid)
+--------------------------+
| Image | <-- Recipe for your container (like a blueprint)
+--------------------------+
| Dockerfile | <-- Instructions to build the image
+--------------------------+
| Container | <-- A running instance of the image
+--------------------------+π Learn more: Docker Images vs Containers
β Good Habits Checklist
- Use
Dockerfileinstead of installing software manually - Document what each command does using comments
- Never hardcode credentials in Dockerfiles
- Always mount volumes to avoid losing work
π₯ Coming Soon: Visual terminal demo β docker build and run
2. Getting Hands-On with Docker
π₯ Visual:
docker runin action (Insert terminal recording GIF)
Installation
Core Commands
# Download an existing image from Docker Hub
docker pull ubuntu
# Build a custom image from a Dockerfile
docker build -t my_image .
# Run an interactive container
docker run -it my_image
# List running containers
docker ps
# Start a container
docker start -ai <container-id>
# Stop a container
docker stop <container-id>
# Remove a container
docker rm <container-id>π Learn more: Docker CLI Reference
β Good Habits Checklist
- Use
--rmto clean up containers automatically when testing - Clean up regularly using
docker system prune - Use
--nameto identify containers more easily