Based on this post, use the following configuration to pass the WSL display to the container.
version: "3"
services:
gui-service:
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
- /mnt/wslg:/mnt/wslg
environment:
- DISPLAY
- WAYLAND_DISPLAY
- XDG_RUNTIME_DIR
- PULSE_SERVER
When this is done, run docker-compose up gui-service
from the WSL terminal.
Other services can extend the gui-service so the configuration does not need to be repeated.
version: "3"
services:
some-service:
extends:
service: gui-service
command: echo "Hello World!"
When this is done, run docker-compose up some-service
from the WSL terminal.
As explained by this post When ROS2 Discovery detects another node on the same network, it will try to use shared memory to communicate. This is faster than using the network. However, if the nodes are running in different containers, they will not be able to use shared memory. To fix this, the following configuration from this post can be used.
version: "3"
services:
some-service:
volumes:
- /dev/shm/:/dev/shm