A simple WebSocket echo server built with websocketd - the tool that turns any command-line program into a WebSocket server.
This container runs a WebSocket server on port 8080 that:
- Echoes back any message you send
- Serves a built-in web UI for testing
- Requires zero code - just configuration
The entire Dockerfile is 12 lines:
FROM alpine
RUN apk add --no-cache wget unzip && \
wget -q -O /tmp/websocketd.zip https://github.com/joewalnes/websocketd/releases/download/v0.4.1/websocketd-0.4.1-linux_amd64.zip && \
unzip -q /tmp/websocketd.zip -d /tmp && \
mv /tmp/websocketd /usr/local/bin/websocketd && \
chmod +x /usr/local/bin/websocketd && \
rm -rf /tmp/websocketd.zip && \
apk del wget unzip
CMD ["websocketd", "--port=8080", "--staticdir=/www", "cat"]That's it. The cat command echoes back what you send. WebSocketd handles all the WebSocket protocol stuff.
# Clone and enter directory
cd sulla-docker-websocket
# Build and run with test UI
just restart "build www"
# Open http://localhost:8080 in your browser| Command | Description |
|---|---|
just |
Show all commands |
just build |
Build Docker image |
just run |
Run container |
just run-with-www |
Run with test UI mounted |
just restart |
Restart container |
just restart "build www" |
Rebuild with www |
just stop |
Stop container |
just logs |
View logs |
just test-http |
Quick HTTP check |
just push |
Push to Docker Hub |
ws://localhost:8080/
Any message sent will be echoed back instantly.
- Testing: Quick WebSocket endpoint for development
- Debugging: Inspect WebSocket traffic with the web UI
- Learning: Simplest possible WebSocket server example
- Integration: Drop-in echo server for CI/CD pipelines
docker run -p 8080:8080 byrdziak/sulla-websocket:latest