2025-10-23 19:29:34 +02:00
2025-10-22 18:33:23 +02:00
2025-10-23 19:29:34 +02:00
2025-10-23 19:29:34 +02:00
2025-10-23 19:29:34 +02:00
2025-10-22 18:33:23 +02:00

Discord in Docker with X11

Run Discord desktop application inside a Docker container with X11 forwarding for display and PulseAudio for sound.

📋 Features

  • Discord desktop app running in an isolated container
  • X11 forwarding for GUI display
  • PulseAudio support for audio
  • Hardware acceleration support
  • Persistent configuration storage
  • Camera/video device support
  • Non-root user for security
  • Easy deployment with Docker Compose

🚀 Quick Start

Prerequisites

  • Docker (20.10 or higher)
  • Docker Compose (1.29 or higher)
  • X11 server running on your host
  • PulseAudio running on your host

Installation

  1. Clone or download this repository

  2. Ensure you have the Discord .deb package

    The project expects discord-0.0.112.deb in the project root. If you have a different version, update the Dockerfile accordingly.

  3. Allow X11 connections (run this command on your host):

    xhost +local:docker
    

    ⚠️ Security Note: This allows Docker containers to connect to your X server. For better security, see the Security Considerations section.

  4. Build and run the container:

    docker-compose up -d
    

    Or build manually:

    docker build -t discord-x11 .
    docker-compose up -d
    

🎮 Usage

Start Discord

docker-compose up -d

Stop Discord

docker-compose down

View logs

docker-compose logs -f

Rebuild after updates

docker-compose down
docker-compose build --no-cache
docker-compose up -d

Remove everything (including config)

docker-compose down -v

📁 Project Structure

docker-discord/
├── Dockerfile              # Container build instructions
├── docker-compose.yml      # Service orchestration
├── entrypoint.sh          # Startup script
├── discord-0.0.112.deb    # Discord installation package
├── .dockerignore          # Build context exclusions
└── README.md              # This file

🔧 Configuration

Environment Variables

The following environment variables are used:

  • DISPLAY: X11 display number (default: :0)
  • QT_X11_NO_MITSHM: Disable MIT-SHM X11 extension
  • PULSE_SERVER: PulseAudio server socket path

Volumes

  • /tmp/.X11-unix: X11 socket for GUI display
  • discord-config: Persistent Discord configuration
  • PulseAudio socket: For audio support

Ports

The container uses network_mode: host to simplify networking and avoid port mapping issues with Discord's voice/video features.

🔍 Troubleshooting

Discord window doesn't appear

  1. Check X11 permissions:

    xhost +local:docker
    
  2. Verify DISPLAY variable:

    echo $DISPLAY
    
  3. Check container logs:

    docker-compose logs
    

No sound

  1. Ensure PulseAudio is running:

    ps aux | grep pulse
    
  2. Verify PulseAudio socket exists:

    ls -la $XDG_RUNTIME_DIR/pulse/native
    
  3. Check PulseAudio configuration allows network access

Video/camera not working

  1. Verify video devices are available:

    ls -la /dev/video*
    
  2. Check user has permissions to access video devices

Graphics performance issues

The container is configured with hardware acceleration through /dev/dri. If you experience issues:

  1. Verify DRI devices exist:

    ls -la /dev/dri/
    
  2. Check GPU drivers are properly installed on the host

"Failed to create secure directory" error

This is usually safe to ignore, but if it persists:

docker-compose down -v
docker-compose up -d

🔒 Security Considerations

X11 Access Control

Instead of xhost +local:docker, use more specific access control:

# Get container hostname
CONTAINER_ID=$(docker ps -qf "name=discord-app")
CONTAINER_HOSTNAME=$(docker inspect -f '{{.Config.Hostname}}' $CONTAINER_ID)

# Grant specific access
xhost +local:$CONTAINER_HOSTNAME

Or use X11 authentication:

# In docker-compose.yml, add:
environment:
  - XAUTHORITY=/tmp/.Xauthority
volumes:
  - ~/.Xauthority:/tmp/.Xauthority:ro

Network Isolation

If you don't need voice/video features, consider removing network_mode: host and explicitly mapping required ports.

User Permissions

The container runs Discord as a non-root user (discord) for improved security.

🆙 Updating Discord

  1. Download the new .deb package
  2. Update the COPY command in Dockerfile with the new filename
  3. Rebuild:
    docker-compose down
    docker-compose build --no-cache
    docker-compose up -d
    

🛠️ Advanced Usage

Custom Discord flags

Pass arguments to Discord via the entrypoint:

docker-compose run discord --enable-features=WebRTCPipeWireCapturer

Running without Docker Compose

docker run -d \
  --name discord \
  --net=host \
  -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix:/tmp/.X11-unix:rw \
  -v discord-config:/home/discord/.config/discord \
  -v $XDG_RUNTIME_DIR/pulse/native:$XDG_RUNTIME_DIR/pulse/native \
  --device /dev/dri \
  --ipc=host \
  discord-x11:latest

Debug mode

Run interactively to debug issues:

docker-compose run --rm discord /bin/bash

📝 Requirements

System Requirements

  • Linux host with X11
  • Docker Engine 20.10+
  • Docker Compose 1.29+
  • 2GB RAM minimum
  • 500MB disk space

Tested On

  • Ubuntu 22.04 LTS
  • Debian 12
  • Arch Linux

🤝 Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Areas for Improvement

  • Wayland support
  • Multi-architecture builds (ARM64)
  • Automated Discord updates
  • Alternative audio backends (ALSA, JACK)
  • Better isolation options

📄 License

This project is provided as-is for educational and personal use. Discord is a trademark of Discord Inc.

⚠️ Disclaimer

This is an unofficial Docker container for Discord. Use at your own risk. Always download Discord from official sources.

🔗 Resources

📧 Support

If you encounter issues:

  1. Check the Troubleshooting section
  2. Review container logs: docker-compose logs
  3. Search existing issues or create a new one

Made with ❤️ for the Discord community

Descripción
No description provided
Readme 34 KiB
Languages
Dockerfile 84.5%
Shell 15.5%