Skip to content

fasterius/docker-X11-interactive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

docker-X11-interactive.sh

A helper script for starting an interactive Docker container with X11 forwarding on MacOS. It enables graphical applications running inside the container to display windows on the host machine, such as when you're plotting something in an R or Python REPL.

Features

  • Runs containers ephemerally (--rm)
  • Attaches a pseudo-TTY (--tty) and runs interactively (--interactive).
  • Automatically mounts the current working directory at /work.
  • Automatically sets the correct X11 display variable (DISPLAY=docker.for.mac.host.internal:0).
  • Ensures XQuartz is running before starting the container.

Installation

Clone this repository and place/symlink the docker-X11-interactive.sh script in your PATH, followed by placing/symlinking the xhost-config.sh script into ~/.xinitrc.d/, for example:

git clone [email protected]:fasterius/docker-X11-interactive.git
cp docker-X11-interactive.sh ~/.local/bin/
mkdir -p ~/.xinitrc.d && cp xinitrc.d/xhost-config.sh ~/.xinitrc.d

Usage

docker-X11-interactive.sh [OPTIONS] IMAGE [ARG...]
  • IMAGE (required): The Docker image to run
  • OPTIONS (optional): Extra flags to pass to docker run (e.g., --gpus all)
  • ARG... (optional): Command to run inside the container (e.g., python)

Examples

Run an R REPL inside a container:

docker-X11-interactive.sh rocker/tidyverse R

Run a Python REPL inside a container:

docker-X11-interactive.sh python:3.13 python

About

Helper script for interactive plotting inside Docker containers on MacOS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages