Project Icon

x11docker

容器内安全运行图形应用程序的开源工具

x11docker是一款开源工具,让用户能在Linux容器中运行图形界面应用和完整桌面环境。它通过运行额外的X服务器来防止X安全漏洞,增强容器隔离性。支持GPU加速、音频、摄像头等功能,适用于Docker和podman等容器平台。x11docker简化了复杂软件的部署,也可用作安全沙盒。该工具在保证安全性的同时,具有低依赖和易用的特点。

x11docker: x11docker logo Run GUI applications in Docker or podman containers.

Avoid X security leaks and enhance container security

DOI

Table of contents

Introduction

x11docker allows to run graphical desktop applications (and entire desktops) in Linux containers.

Software can be installed in a deployable image with a rudimentary Linux system inside. This can help to run or deploy software that is difficult to install on several systems due to dependency issues. It is possible to run outdated versions or latest development versions side by side. Files to work on can be shared between host and container.

x11docker wiki provides some how-to's for basic setups without x11docker.

Docker Desktop or Docker Engine

Since a while Docker distributes a version called "Docker Desktop" that runs Docker in a QEMU VM. x11docker is not designed to support this VM based version. Instead, use x11docker with the native "Docker Engine Server version" that uses your host kernel to run containers.

  • If you install Docker from your distribution's repository, you'll likely get this native version.
  • The supported native Docker Engine package name is mostly docker.io or docker-ce, in opposite to the non-supported VM based docker-desktop package.
  • If you prefer podman over Docker, you don't need to care about this difference.

TL;DR

For a quick start:

  • Install x11docker with:
    curl -fsSL https://raw.githubusercontent.com/mviereck/x11docker/master/x11docker | sudo bash -s -- --update
    
  • Install dependencies:
    • Either pull image x11docker/xserver or install at least nxagent or xpra and xephyr.
  • Run a GUI in container with:
    x11docker IMAGENAME [COMMAND]
    
  • Add options:
    • --desktop for a desktop environment in image.
    • --gpu for hardware acceleration.
  • Examples:
    x11docker x11docker/xfce thunar
    x11docker --desktop x11docker/xfce
    x11docker --gpu x11docker/xfce glxgears
    

Features

  • Focus on security:
    • Avoids X security leaks by running additional X servers.
    • Restricts container capabilities to bare minimum.
    • Container user is same as host user to avoid root in container.
  • Low dependencies:
    • No obliging dependencies on host beside X and one of docker, podman or nerdctl. Recommended: nxagent and Xephyr, alternatively image x11docker/xserver.
    • No dependencies inside of images except for some optional features.
  • Several optional features like GPU, sound, webcam and printer support.
  • Remote access with SSH, VNC or HTML5 possible.
  • Easy to use. Examples:
    • x11docker x11docker/fvwm xterm
    • x11docker --desktop --size 320x240 x11docker/lxde (needs nested X server Xephyr) retro terminal cathode LXDE in xpra

Supported systems

x11docker runs on Linux and (with some setup and limitations) on MS Windows. x11docker does not run on macOS except in a Linux VM.

Terminal syntax

Just type x11docker IMAGENAME [COMMAND].

  • Get an overview of options with x11docker --help.
    • For desktop environments in image add option -d, --desktop.
    • For internet access use option -I, --network.
    • To run without X at all use option -t, --tty.
    • Get an interactive TTY with option -i, --interactive.
    • See generated container backend command (and further infos) with option --debug.
  • If startup fails, look at chapter Troubleshooting.

General syntax:

Usage:
To run a container on a new X server:
  x11docker IMAGE
  x11docker [OPTIONS] IMAGE [COMMAND]
  x11docker [OPTIONS] -- IMAGE [COMMAND [ARG1 ARG2 ...]]
  x11docker [OPTIONS] -- CUSTOM_RUN_OPTIONS -- IMAGE [COMMAND [ARG1 ARG2 ...]]
To run a host application on a new X server:
  x11docker [OPTIONS] --backend=host COMMAND
  x11docker [OPTIONS] --backend=host -- COMMAND [ARG1 ARG2 ...]
  x11docker [OPTIONS] --backend=host -- -- COMMAND [ARG1 ARG2 ...] -- [ARG3]
To run only an empty new X server:
  x11docker [OPTIONS] --xonly

CUSTOM_RUN_OPTIONS are just added to the docker|podman|nerdctl run command without a serious check by x11docker.

Options

Description of some commonly used feature options.

Choice of X servers and Wayland compositors

If no X server option is specified, x11docker automatically chooses one depending on installed dependencies and on given or missing options --desktop, --gpu and --wayland. Most recommended are nxagent and Xephyr.

Desktop or seamless mode

x11docker assumes that you want to run a single application in seamless mode, i.e. a single window on your regular desktop. If you want to run a desktop environment in image, add option --desktop.

  • Seamless mode is supported with options --nxagent and --xpra. As a fallback insecure option --hostdisplay is possible.
  • Desktop mode with --desktop is supported with all X server options except --hostdisplay. If available, x11docker prefers --xephyr and --nxagent.
  • Special case: Single applications with a window manager (option --wm).
    • If neither nxagent nor xpra are installed, but x11docker finds a desktop capable X server like Xephyr, it avoids insecure option --hostdisplay and runs Xephyr with a window manager.

Internet access

By default x11docker disables Network access for containers with --network=none because it targets best possible container isolation. To allow internet access set option -I or --network.

Shared folders, volumes and HOME in container

Changes in a running container system will be lost, the created container will be discarded. For persistent data storage you can share host directories or volumes:

  • Option -m, --home creates a host directory in ~/.local/share/x11docker/IMAGENAME that is shared with the container and mounted as its HOME directory. Files in container home and user configuration changes will persist. x11docker creates a softlink from ~/.local/share/x11docker to ~/x11docker.
    • You can specify another host directory for container HOME with --home=DIR.
    • You can specify a volume for container HOME with --home=VOLUME.
  • Option --share PATH mounts a host file or folder at the same location in container.
    • You can also specify a volume with --share VOLUME.
    • --share PATH:ro restricts to read-only access.
    • Device files in /dev are supported, too.
  • Special cases for $HOME:
    • --home=$HOME will use your host home as container home. Discouraged, use with care.
    • --share $HOME will symlink your host home as a subfolder of container home.

Note that x11docker copies files from /etc/skel in container to HOME if HOME is empty. That allows to provide predefined user configurations in the image.

GPU hardware acceleration

Hardware acceleration for OpenGL is possible with option -g, --gpu.

Clipboard

Clipboard sharing is possible with option -c, --clipboard [=ARG].

  • Optional arguments superv and altv only provide host clipboard content to container if keys [SUPER][v] or [ALT][v] are pressed.
  • Optional argument oneway only transfers clipboard content from container to host.

Sound

Sound is possible with options -p, --pulseaudio and --alsa.

  • For pulseaudio sound with --pulseaudio you need pulseaudio on host and pulseaudio (at least the pulseaudio client libraries) in image. Compare wiki: feature dependencies.
  • For ALSA sound with --alsa you might need to specify a sound card with e.g. --alsa=Generic. Get a list of available sound cards with aplay -l.

Webcam

Webcams on host can be shared with option --webcam.

  • If webcam application in image fails, install --gpu dependencies in image. Compare wiki: feature dependencies.
  • guvcview needs --pulseaudio or --alsa.
  • cheese and gnome-ring need --init=systemd.

Printer

Printers on host can be provided to container with option --printer.

  • It needs cups on host, the default printer server for most linux distributions.
  • The container needs cups client libraries in image. Compare wiki: feature dependencies.

Language locales

x11docker provides option --lang for flexible language locale settings.

  • --lang without an argument sets LANG in container to same as on host. Same as --lang=$LANG
  • x11docker will check on container startup if the desired locale is already present in image and enable it.
  • If x11docker does not find the locale, it creates it on container startup. This needs some locale packages in image. Compare wiki: feature dependencies.
  • Examples: --lang=de for German, --lang=zh_CN for Chinese, --lang=ru for Russian, --lang=$LANG for your host locale.
  • For support of chinese, japanese and korean characters install a font like fonts-arphic-uming in image.
  • Keyboard input methods like fcitx-pinyin are possible with some container setup. Compare ticket #269.

Wayland

To run Wayland instead of an X server x11docker provides options --wayland, --weston, --kwin and --hostwayland. For further description loot at wiki: Description of Wayland options.

  • Option --wayland automatically sets up a Wayland environment. It regards option --desktop.
  • Options --weston and --kwin run Wayland compositors weston or kwin_wayland.
  • Option --hostwayland can run
项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

吐司

探索Tensor.Art平台的独特AI模型,免费访问各种图像生成与AI训练工具,从Stable Diffusion等基础模型开始,轻松实现创新图像生成。体验前沿的AI技术,推动个人和企业的创新发展。

Project Cover

SubCat字幕猫

SubCat字幕猫APP是一款创新的视频播放器,它将改变您观看视频的方式!SubCat结合了先进的人工智能技术,为您提供即时视频字幕翻译,无论是本地视频还是网络流媒体,让您轻松享受各种语言的内容。

Project Cover

美间AI

美间AI创意设计平台,利用前沿AI技术,为设计师和营销人员提供一站式设计解决方案。从智能海报到3D效果图,再到文案生成,美间让创意设计更简单、更高效。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号