Theme
Stage 1 · lesson 2 of 5 · 30 min

Living inside the container

You will: Know where your code, your build output and your shell actually live, and which edits need a rebuild.

Builds on Docker, and nothing else.

One container holds everything, deliberately. Splitting ROS nodes across containers means fighting the middleware's network discovery, and that is not what this course is about. The split comes later, when there is a real network boundary to model.

Inside it, three kinds of storage do three different jobs:

  • src/ is bind-mounted. It is what you edit, so your editor on the host and the build inside the container see the same files.
  • build/, install/ and log/ are named volumes. colcon, the ROS build tool, writes tens of thousands of small files. Through the file-sharing layer Docker Desktop uses on macOS, that I/O would dominate every build. Keeping it inside Docker's own storage also keeps generated files out of your checkout.
  • ROS is sourced twice, on purpose. The entrypoint covers docker compose run; a profile script covers docker compose exec, which bypasses the entrypoint entirely. Without the second, make build works and make shell mysteriously does not.

The workspace is built with --symlink-install: installed files are symlinks back into src/. So editing a YAML, xacro or launch file takes effect when you relaunch, with no rebuild. Adding a file still needs make build, because the symlink for it does not exist yet. That distinction is the single most common "why didn't my change apply?" in this project.

One more setting is worth knowing about before it bites you. ROS 2 discovers other nodes automatically across the network, which is convenient until two developers on one Wi-Fi network silently join each other's robot. The container limits discovery to itself.

In the simulation

The named poses under the joints panel come from the profile, config/so101_follower.yaml, which --symlink-install links rather than copies: edit a pose there and it applies on relaunch, with no rebuild. Send the arm to them and read the numbers the file holds.

Kinematic: joints move at their real speed limit, but there is no gravity, no load and no physics. That is what the steps below are for.

The SO-101 loads as you reach it.

In this lesson

  1. Open Inspect, on its /joint_states view.
  2. Press the ready pose button. Compare the positions with the profile's line: ready: [0.0, -0.6, 0.8, 0.5, 0.0].
  3. Send it to rest, the folded pose.
  4. Now home it with h (or the home button).

Do it

  1. Open a shell inside the container.

    make shell
    

    Expect: A prompt inside the container, with ROS already sourced.

  2. Inside it, confirm the versions the project pins.

    printenv ROS_DISTRO
    gz sim --versions
    

    Expect: jazzy, and a Gazebo version starting with 8 — that is Harmonic.

  3. See the symlinks --symlink-install created.

    ls -l /ws/install/threevn_robot_description/share/threevn_robot_description/config/
    

    Expect: Each profile is a link pointing back into /ws/src.

  4. Check the discovery setting, then leave the shell.

    printenv ROS_AUTOMATIC_DISCOVERY_RANGE
    exit
    

    Expect: LOCALHOST.

  5. From the host, find the named volumes that hold the build.

    docker volume ls | grep -E "_(build|install|log)$"
    

    Expect: Three volumes: docker_build, docker_install and docker_log. The prefix is Compose's project name, and Compose takes that from the folder the compose file is in, docker/, not from the repository.

You will know it worked when: You can say, for any file in the repository, whether changing it needs make build, a relaunch, or nothing.

When it goes wrong

You changed something and nothing happened.

Why: You added a file rather than editing one. --symlink-install links files that existed at build time.

Fix: Run make build, then relaunch.

Tests fail with FileNotFoundError naming a file you deliberately deleted.

Why: --symlink-install never removes a link whose source has gone, so a dead link stays in install/ and anything that lists that directory trips over it. Found by running this course's own "design your own arm" project.

Fix: make build — it now deletes dangling links after every build and prints each one it removes.

ros2 run finds a new executable and then fails with StopIteration.

Why: A new Python entry point was added. --symlink-install refreshes source files but not the package metadata that maps the command name to a function.

Fix: Rebuild that one package from scratch: inside make shell, remove /ws/build/<pkg> and /ws/install/<pkg>, then colcon build --symlink-install --packages-select <pkg>.

Terms

Bind mount
A host directory mapped into a container, so both see the same files. Right for source code you edit.
Named volume
Storage Docker manages itself. Faster than a bind mount on macOS for many small files, and invisible in your checkout — right for build output.
colcon's --symlink-install: installed files are links to the sources, so edits apply without a rebuild but new files do not.
DDS discovery
How ROS 2 nodes find each other automatically over the network. Limited here with ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST.

Every term in the course: glossary.

Check yourself

Answer in your head first, then open it.

Why are build/, install/ and log/ named volumes rather than folders in your checkout?

colcon writes tens of thousands of small files, and on macOS the bind-mount layer makes that I/O dominate every build. Volumes are fast, and they keep generated artefacts out of the repository.

You edit an existing launch file and the change applies on relaunch. You add a new one and ros2 launch cannot find it. Why the difference?

With --symlink-install, an existing file is already a symlink into src/, so edits show through. A new file has no installed symlink until make build creates one.

Stretch

Find the line in docker/compose.yml that would let your container join a colleague's ROS graph if it were removed. Explain what you would see if it were — and why that would be harder to diagnose than an error.

Hint

Look for the discovery setting from the last step. Without it, nodes from another machine appear in your ros2 node list, and their messages arrive on your topics.

Going deeper