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
-
Clone or download this repository
-
Ensure you have the Discord .deb package
The project expects
discord-0.0.112.debin the project root. If you have a different version, update theDockerfileaccordingly. -
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.
-
Build and run the container:
docker-compose up -dOr 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 extensionPULSE_SERVER: PulseAudio server socket path
Volumes
/tmp/.X11-unix: X11 socket for GUI displaydiscord-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
-
Check X11 permissions:
xhost +local:docker -
Verify DISPLAY variable:
echo $DISPLAY -
Check container logs:
docker-compose logs
No sound
-
Ensure PulseAudio is running:
ps aux | grep pulse -
Verify PulseAudio socket exists:
ls -la $XDG_RUNTIME_DIR/pulse/native -
Check PulseAudio configuration allows network access
Video/camera not working
-
Verify video devices are available:
ls -la /dev/video* -
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:
-
Verify DRI devices exist:
ls -la /dev/dri/ -
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
- Download the new
.debpackage - Update the
COPYcommand inDockerfilewith the new filename - 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:
- Check the Troubleshooting section
- Review container logs:
docker-compose logs - Search existing issues or create a new one
Made with ❤️ for the Discord community