This project enables X11 forwarding and audio playback from remote Docker containers to local Windows/Mac clients. Run GUI apps and play audio in containers on remote servers, with output on your local machine. Supports tools like matplotlib and pyaudio. Create a seamless, native-like experience for remote development environments.
- Download PulseAudio for Windows from the official website.
- Extract the downloaded ZIP file to a folder (e.g.,
C:\pulseaudio-1.1
). - Edit the configuration file (located at
C:\pulseaudio-1.1\etc\pulse\default.pa
):
load-module module-native-protocol-tcp auth-ip-acl=0.0.0.0/0 auth-anonymous=1
load-module module-esound-protocol-tcp auth-ip-acl=0.0.0.0/0 auth-anonymous=1
load-module module-waveout sink_name=output source_name=input
set-default-sink output
set-default-source input
-
Edit
C:\pulseaudio-1.1\etc\pulse\daemon.conf
Setexit-idle-time = -1
to prevent PulseAudio from exiting when idle. -
Run PulseAudio: Open Command Prompt as Administrator and run:
"C:\pulseaudio-1.1\bin\pulseaudio.exe" --exit-idle-time=-1
- Run the following commands in your Docker container to install PulseAudio:
sudo apt-get update
sudo apt-get install -y pulseaudio alsa-utils
- Create necessary directories
mkdir -p /var/run/dbus
mkdir -p /var/run/pulse
mkdir -p /root/.config/pulse
- Generate machine-id
dbus-uuidgen > /var/lib/dbus/machine-id
- If your dbus-daemon is not running, start it:
dbus-daemon --system --fork
- Configure PulseAudio:
cat << EOF > /etc/pulse/client.conf
# default-server = tcp:<WINDOWS_IP>:4713 # Will be set via environment variable
autospawn = no
daemon-binary = /bin/true
enable-shm = false
EOF
- Export the PulseAudio server address:
export PULSE_SERVER=tcp:<CLIENT_IP>:4713
Replace <CLIENT_IP>
with the IP address of your Windows/Mac client.
- Check if PulseAudio is running:
pactl info
- Test audio playback:
# Default audio test
speaker-test -c 2 -t wav
# Play a test audio file
aplay -D pulse test_audio.wav
- Test audio recording:
# Default audio recording
arecord -f cd -t wav -d 5 output.wav
aplay -D pulse output.wav
# Record audio from the default microphone using pyaudio
python3 pyaudio_test_microphone.py
aplay -D pulse output.wav
- Ensure SSH is installed and running in your Docker container:
sudo apt-get update
sudo apt-get install -y openssh-server
sudo service ssh start
# Set `PermitRootLogin yes` in /etc/ssh/sshd_config if you want to SSH as root
- Edit
/etc/ssh/sshd_config
to include:
X11Forwarding yes
X11UseLocalhost no
- Restart the SSH service:
# For systemctl based systems
sudo systemctl restart ssh
# For systems using service
sudo service ssh restart
- Install X11 and GUI applications in your Docker container:
sudo apt-get update
sudo apt-get install -y xauth x11-apps
- Install an SSH client like PuTTY.
- Install an X11 server like Xming.
- Open PuTTY and navigate to
Connection > SSH > X11
. - Check
Enable X11 forwarding
. - Navigate back to
Session
, enter the hostname and port of your server, and clickOpen
. - Install Xming and run it.
- Open PuTTY and SSH into your server.
- Run a GUI application like
xeyes
orgedit
.