initial commit

Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
ale
2025-10-22 18:33:23 +02:00
commit 456d7051d8
Se han modificado 5 ficheros con 447 adiciones y 0 borrados

30
.dockerignore Archivo normal
Ver fichero

@@ -0,0 +1,30 @@
# Git
.git
.gitignore
.gitattributes
# Documentation
README.md
*.md
# Docker
.dockerignore
docker-compose.override.yml
# IDE
.vscode
.idea
*.swp
*.swo
*~
# OS
.DS_Store
Thumbs.db
# Logs
*.log
# Temporary files
*.tmp
*.temp

60
Dockerfile Archivo normal
Ver fichero

@@ -0,0 +1,60 @@
# Base image with Ubuntu
FROM ubuntu:22.04
# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive
# Install dependencies for Discord and X11
RUN apt-get update && apt-get install -y \
wget \
gnupg2 \
ca-certificates \
libgtk-3-0 \
libnotify4 \
libnss3 \
libxss1 \
libxtst6 \
xdg-utils \
libatspi2.0-0 \
libuuid1 \
libappindicator3-1 \
libsecret-1-0 \
libgbm1 \
libasound2 \
libdrm2 \
libxshmfence1 \
x11-apps \
pulseaudio \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user to run Discord
RUN useradd -m -s /bin/bash discord && \
mkdir -p /home/discord/.config
# Copy the Discord .deb package
RUN wget -O /tmp/discord.deb https://discord.com/api/download?platform=linux&format=deb
# Install Discord
RUN dpkg -i /tmp/discord.deb || true && \
apt-get update && \
apt-get -f install -y && \
rm /tmp/discord.deb && \
rm -rf /var/lib/apt/lists/*
# Set up user permissions
RUN chown -R discord:discord /home/discord
# Switch to non-root user
USER discord
WORKDIR /home/discord
# Set environment variables for X11
ENV DISPLAY=:0
ENV QT_X11_NO_MITSHM=1
# Copy entrypoint script
COPY --chown=discord:discord entrypoint.sh /home/discord/entrypoint.sh
RUN chmod +x /home/discord/entrypoint.sh
# Start Discord
ENTRYPOINT ["/home/discord/entrypoint.sh"]

312
README.md Archivo normal
Ver fichero

@@ -0,0 +1,312 @@
# 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**

33
docker-compose.yml Archivo normal
Ver fichero

@@ -0,0 +1,33 @@
version: '3.8'
services:
discord:
build:
context: .
dockerfile: Dockerfile
container_name: discord-app
image: discord-x11:latest
network_mode: host
environment:
- DISPLAY=${DISPLAY}
- QT_X11_NO_MITSHM=1
- PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native
volumes:
# X11 socket for GUI
- /tmp/.X11-unix:/tmp/.X11-unix:rw
# Discord config persistence
- discord-config:/home/discord/.config/discord
# PulseAudio for sound
- ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native
- ~/.config/pulse/cookie:/home/discord/.config/pulse/cookie:ro
devices:
# Video devices for camera support
- /dev/dri:/dev/dri
ipc: host
security_opt:
- seccomp:unconfined
restart: unless-stopped
volumes:
discord-config:
driver: local

12
entrypoint.sh Archivo normal
Ver fichero

@@ -0,0 +1,12 @@
#!/bin/bash
# Entrypoint script for Discord container
# Wait for X11 socket to be available
while [ ! -S /tmp/.X11-unix/X${DISPLAY#*:} ]; do
echo "Waiting for X11 socket..."
sleep 1
done
echo "Starting Discord..."
exec /usr/bin/discord --no-sandbox "$@"