VS Code: Attach to a Duckiebot
Contents
{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
VS Code with the Container Tools extension installed
Network access to the Duckiebot.
What you will get
An IDE (VSCode) connected to the running devcontainer on the Duckiebot.
Add the Docker Context#
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"
In VS Code, select this context in the Docker view (next section shows how).
Attach Visual Studio Code#
Locate the target container (e.g.,
dts-run-dt-core). Scroll if needed.
Fig. 146 Scroll through the containers list to locate the target container.#
Fig. 147 Focus the container entry so its context actions are available.#
Right‑click the container and choose “Attach Visual Studio Code”.
Fig. 148 Open the container’s context menu and select “Attach Visual Studio Code”.#
Start editing on the Duckiebot#
A new window opens inside the container. Open your project folder and start editing, running terminals, or using extensions as needed.
Fig. 149 The new VS Code window is attached to the container.#
Use the integrated terminal inside this window for container-scoped commands.
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
rostopicwork 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.