Skip to content
github-actions[bot] edited this page Apr 12, 2026 · 4 revisions

Using the Raylib Container (Linux)

Quick reference for running the Raylib Docker container on Linux.

Home: Home

Prerequisites

  • Allow containers to access the display:
# Allow connections from Docker on the current graphical session
xhost +local:docker
  • (Optional) Add your user to the docker group to avoid sudo:
sudo usermod -aG docker $USER

Building the image (if needed)

docker build -t raylib_container .

Running the container

Hardware-accelerated (recommended):

docker run -it --rm \
  -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -v ./user_code:/app/user_code \
  --device /dev/dri:/dev/dri \
  raylib_container

Software rendering (fallback):

docker run -it --rm \
  -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -v ./user_code:/app/user_code \
  -e LIBGL_ALWAYS_SOFTWARE=1 \
  raylib_container

Verify graphics connection

Inside the container, run:

xeyes

Developing inside the container

Place your source in the host user_code directory (mounted as /app/user_code). Example compile inside the container:

cd /app/user_code
gcc my_game.c -o my_game -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
./my_game

Reverting host changes

  • Revoke display access: xhost -local:docker
  • Remove user from docker group (if added): sudo gpasswd -d $USER docker

Troubleshooting

  • "Cannot connect to the Docker daemon": verify docker group membership or use sudo.
  • "cannot open display": ensure xhost +local:docker ran in the current graphical session and that DISPLAY is passed.
  • Hardware acceleration errors (MESA/drm): try the software rendering command above.

For more details and platform-specific notes see overview.md.

Wiki links: Home overview macos/compatibility windows/usage

Clone this wiki locally