{vscode-dev-on-db}

VS Code: Attach to a Duckiebot#

This guide shows how to attach Visual Studio Code to a running container on your Duckiebot using the Container Tools extension. This lets you edit code and use the VS Code UI directly inside the robot’s container.

What you will need

What you will get

  • An IDE (VSCode) connected to the running devcontainer on the Duckiebot.

Add the Docker Context#

  1. Create a Docker context that points to your Duckiebot over TCP on port 2375:

docker context create ROBOT_NAME --docker "host=tcp://ROBOT_NAME.local:2375"
  1. In VS Code, select this context in the Docker view (next section shows how).

Attach Visual Studio Code#

  1. Locate the target container (e.g., dts-run-dt-core). Scroll if needed.

../../../_images/step-5.png

Fig. 146 Scroll through the containers list to locate the target container.#

../../../_images/step-6.png

Fig. 147 Focus the container entry so its context actions are available.#

  1. Right‑click the container and choose “Attach Visual Studio Code”.

../../../_images/step-7.png

Fig. 148 Open the container’s context menu and select “Attach Visual Studio Code”.#

Start editing on the Duckiebot#

  1. A new window opens inside the container. Open your project folder and start editing, running terminals, or using extensions as needed.

../../../_images/step-8.png

Fig. 149 The new VS Code window is attached to the container.#

  1. Use the integrated terminal inside this window for container-scoped commands.

../../../_images/step-9.png

Fig. 150 Use terminals and extensions as usual, now running inside the container.#

Tips#

  • Terminals: Use the integrated terminal for commands that must run inside the container.

  • ROS tools: If the container has ROS installed and is connected to the robot’s ROS network, tools like rostopic work from the terminal.

  • Persisting changes: Changes inside a container are automatically synced to your laptop using mutagen.

Troubleshooting#

Troubleshooting

SYMPTOM

Cannot see Duckiebot containers in VS Code.

RESOLUTION

Ensure the Docker context is set to the Duckiebot and that containers are running. Switch context from the status bar in the Container tab.

Troubleshooting

SYMPTOM

Attach Visual Studio Code is missing from the menu.

RESOLUTION

Install/update the VS Code Container Tools extension and right‑click directly on a running container.