version: "3.9" services: # in docker compose, service are definitions of your docker containers hello-world: # for this example I am using a very simple docker build for reference: hello-world (builds very fast) image: ghcr.io/bjoernellens1/ros2_docker_template/hello-world # hello-world image. No prefix means it defaults the image registry to dockerhub build: context: . dockerfile: docker/hello-world.Dockerfile # the Dockerfile speciefies the steps taken in the build process. tags: - ghcr.io/bjoernellens1/ros2_docker_template/hello-world target: hello-world # here you can explicitly specify the build target in the Dockerfile if you want only a specific build step for this service. my_example: # this already represents a more complex ros2 build process. image: ghcr.io/bjoernellens1/ros2_docker_template/my_example # hello-world image. No prefix means it defaults the image registry to dockerhub build: context: . dockerfile: docker/my_example.Dockerfile # the Dockerfile speciefies the steps taken in the build process. tags: - ghcr.io/bjoernellens1/ros2_docker_template/my_example environment: # Allows graphical programs in the container. - DISPLAY=${DISPLAY} - QT_X11_NO_MITSHM=1 - NVIDIA_DRIVER_CAPABILITIES=all # For Nvidia hardware acceleration (CUDA, ...). This might additionally need some extra tools installed (Nvidia Container Toolkit?) volumes: # Allows graphical programs in the container. - /tmp/.X11-unix:/tmp/.X11-unix:rw - ${XAUTHORITY:-$HOME/.Xauthority}:/root/.Xauthority network_mode: host # host networking makes life easier