...
- Install WSL2 on your computer. This is Windows Subsystem for Linux, which allows developers to run a Linux environment without a separate virtual machine or dual booting. It's used by Docker to run its backend. If you're on Windows 10 version 2004 and higher (Build 19041 and higher), visit this page; all you have to do is run one command in Windows Powershell! If you're on an older build, see these manual steps.
- Install Docker Desktop via the instructions.
- Install VcXsrv, an application for the X Window System Display server. The X Window System Display server used by various operating systems for running their graphical applications. We'll VcXserv on Windows, and then we'll send all the graphical application traffic from our Docker container to our X server running on Windows, allowing us to run our graphical applications straight out of the box.
- We'll need to change the display number on VcXsrv to 0 so Docker knows where to find our server. Navigate to `C:\Program Files\VcXsrv`, or wherever you installed VcXsrv, and launch
xlaunch.exe
. In the display settings window, navigate to the bottom and change Display Number from -1 to 0, and hit next until you can closexlaunch
. - Fantastic, you've installed everything you need to run Docker graphically! Next up, open Windows Powershell (as an administrator should help). Next, we're going to pull down and show you how to use a pre-built Ubuntu 20.04 image with ROS2 Foxy installed, so you can get going with the rest of the software training.
- Run
docker pull osrf/ros-:foxy-desktop
in Powershell. This will download the image, straight from the Open Source Robotics Foundation (the people behind ROS). If you need ROS2 Galactic for post-training dev work, useosrf/ros-galactic-desktop
. - Next, we'll go ahead and run this image. Before we do this, we'll need to pass a lot of flags to the
docker run
command, so I'll explain them here:-
the -v flag shares a folder from your host machine (your Windows computer) to the Docker container. In this example, we're mappingv C:\Users\path\to\folder:/code/dev_ws
C:\Users\path\to\folder
to/code/dev_ws
in the container. Any changes made in the Docker container will be reflected on your folder on Windows, and any changes made to your folder on Windows will be reflected in the Docker container. This is incredibly useful, because now we can code on Windows but run and test on the container in Linux.-it
runs the container with an interactive shell. If you didn't pass-it
, the container would run in the background and you would have no way of interacting with it (unless you useddocker exec
later).-e
sets an environment variable inside the Docker container. We'll be using this to tell the Ubuntu container where to send the graphical traffic via theDISPLAY
environment variable.--name
sets a name for the Docker container for use later. We'll call our Docker containeruwrt_dev_container
.
- Now, the actual
docker run
command you'll be using; please change the first path of the-v
flag to an absolute path of wherever you plan on storing your ROS2 workspace. In this example, we're sharing our entireC:\Users\Owner\Documents\Code
folder to the container:-
docker run --name uwrt_dev_container -e DISPLAY=host.docker.internal:0.0 -it -v C:\Users\Owner\Documents\code:/code/dev_ws osrf/ros-:foxy-desktop
-
- You should now be inside the Docker container! Feel free to look around by running any typical Linux commands. ROS2 Foxy (or Galactic, whichever you chose) is pre-installed in this container.
- Run
- Useful Docker commands from here out:
- Stopping the container: `docker stop container-name`
- Restarting the container after stopping:
docker start container-name
- Pausing the container:
docker pause container-name
- Unpausing the container: `docker pause container--name`
- Opening a new shell for the container: `docker exec -it <mycontainer> bash`
...