# 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): ```bash xhost +local:docker ``` > ⚠️ **Security Note**: This allows Docker containers to connect to your X server. For better security, see the [Security Considerations](#-security-considerations) section. 4. **Build and run the container**: ```bash docker-compose up -d ``` Or build manually: ```bash docker build -t discord-x11 . docker-compose up -d ``` ## 🎮 Usage ### Start Discord ```bash docker-compose up -d ``` ### Stop Discord ```bash docker-compose down ``` ### View logs ```bash docker-compose logs -f ``` ### Rebuild after updates ```bash docker-compose down docker-compose build --no-cache docker-compose up -d ``` ### Remove everything (including config) ```bash 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: ```bash xhost +local:docker ``` 2. Verify DISPLAY variable: ```bash echo $DISPLAY ``` 3. Check container logs: ```bash docker-compose logs ``` ### No sound 1. Ensure PulseAudio is running: ```bash ps aux | grep pulse ``` 2. Verify PulseAudio socket exists: ```bash ls -la $XDG_RUNTIME_DIR/pulse/native ``` 3. Check PulseAudio configuration allows network access ### Video/camera not working 1. Verify video devices are available: ```bash 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: ```bash 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: ```bash docker-compose down -v docker-compose up -d ``` ## 🔒 Security Considerations ### X11 Access Control Instead of `xhost +local:docker`, use more specific access control: ```bash # 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: ```bash # 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: ```bash docker-compose down docker-compose build --no-cache docker-compose up -d ``` ## 🛠️ Advanced Usage ### Custom Discord flags Pass arguments to Discord via the entrypoint: ```bash docker-compose run discord --enable-features=WebRTCPipeWireCapturer ``` ### Running without Docker Compose ```bash 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: ```bash 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 - [Discord Official Website](https://discord.com/) - [Docker Documentation](https://docs.docker.com/) - [X11 Forwarding Guide](https://www.x.org/wiki/) - [PulseAudio Documentation](https://www.freedesktop.org/wiki/Software/PulseAudio/) ## 📧 Support If you encounter issues: 1. Check the [Troubleshooting](#-troubleshooting) section 2. Review container logs: `docker-compose logs` 3. Search existing issues or create a new one --- **Made with ❤️ for the Discord community**