Skip to content

Docker Help

Kashu Yamazaki edited this page Mar 11, 2024 · 3 revisions

Using GUI Apps with Docker

  1. Allow local X11 connections
xhost local:root
  1. Run docker with options
  • Intel GPU
# Run docker image with following options
docker run --device=/dev/dri:/dev/dri \
    -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY
  • NVIDIA GPU
# Run docker image with following options
docker run  --gpus 'all,"capabilities=compute,utility,graphics"' \
    -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY
  • CPU rendering (without a GPU)
# Run docker image with following options
docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY

Using Host Network

use the host machine's network stack directly, instead of creating a separate virtual network for the container.

docker run --network host

With --network host, you don't need to perform explicit port mapping (-p or --publish) because the container's ports are directly exposed on the host machine's network interfaces.

Using Host Device

docker run --privileged -v /dev:/dev

The --privileged flag is a Docker command-line option that gives extended privileges to a Docker container. When you run a container with --privileged, the container is given almost all the capabilities of the host machine, including direct access to the host's kernel, devices, and other resources.

Copying files from Docker container to host

In order to copy a file from a container to the host, you can use the command

docker cp <containerId>:/file/path/within/container /host/path/target