Docker provides an excellent way to run Lavalink with consistent environments and easy deployment. This guide covers everything from basic setup to production-ready configurations.
Docker is ideal when:
Ubuntu/Debian:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker \$USER
Verify installation:
docker --version
docker compose version
The easiest approach uses the official Lavalink image:
docker run -d \
--name lavalink \
-p 2333:2333 \
-v \$(pwd)/application.yml:/opt/Lavalink/application.yml \
ghcr.io/lavalink-devs/lavalink:4
server:
port: 2333
address: 0.0.0.0
lavalink:
server:
password: "your_secure_password"
sources:
youtube: true
soundcloud: true
bandcamp: true
twitch: true
http: true
local: false
version: '3.8'
services:
lavalink:
image: ghcr.io/lavalink-devs/lavalink:4
container_name: lavalink
restart: unless-stopped
ports:
- "2333:2333"
volumes:
- ./application.yml:/opt/Lavalink/application.yml
environment:
- _JAVA_OPTIONS=-Xmx1G
docker compose up -d
docker compose logs -f lavalink
For more control, create a custom Dockerfile:
FROM eclipse-temurin:21-jre-alpine
# Create app directory
WORKDIR /opt/Lavalink
# Download Lavalink
ARG LAVALINK_VERSION=4.0.4
RUN wget -O Lavalink.jar \
"https://github.com/lavalink-devs/Lavalink/releases/download/\${LAVALINK_VERSION}/Lavalink.jar"
# Copy configuration
COPY application.yml .
# Expose port
EXPOSE 2333
# Set JVM options
ENV JAVA_OPTS="-Xms256M -Xmx1G -XX:+UseG1GC"
# Run Lavalink
CMD java \$JAVA_OPTS -jar Lavalink.jar
docker build -t my-lavalink .
docker run -d -p 2333:2333 my-lavalink
version: '3.8'
services:
lavalink:
image: ghcr.io/lavalink-devs/lavalink:4
container_name: lavalink
restart: always
ports:
- "2333:2333"
volumes:
- ./application.yml:/opt/Lavalink/application.yml:ro
- ./plugins:/opt/Lavalink/plugins:ro
environment:
- _JAVA_OPTIONS=-Xms512M -Xmx1G -XX:+UseG1GC -XX:+ParallelRefProcEnabled
deploy:
resources:
limits:
cpus: '2'
memory: 1.5G
reservations:
cpus: '0.5'
memory: 512M
healthcheck:
test: ["CMD", "wget", "-q", "-O", "-", "http://localhost:2333/version"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
server:
port: 2333
address: 0.0.0.0
lavalink:
server:
password: "\${LAVALINK_PASSWORD:changeme}"
sources:
youtube: true
soundcloud: true
bandcamp: true
twitch: true
http: true
local: false
bufferDurationMs: 400
frameBufferDurationMs: 5000
youtubePlaylistLoadLimit: 6
playerUpdateInterval: 5
youtubeSearchEnabled: true
soundcloudSearchEnabled: true
gc-warnings: true
metrics:
prometheus:
enabled: true
endpoint: /metrics
logging:
level:
root: INFO
lavalink: INFO
lavalink/
├── docker-compose.yml
├── application.yml
└── plugins/
└── youtube-plugin-1.0.0.jar
services:
lavalink:
image: ghcr.io/lavalink-devs/lavalink:4
volumes:
- ./application.yml:/opt/Lavalink/application.yml
- ./plugins:/opt/Lavalink/plugins
plugins:
youtube:
enabled: true
clients:
- MUSIC
- WEB
version: '3.8'
services:
lavalink-1:
image: ghcr.io/lavalink-devs/lavalink:4
container_name: lavalink-1
ports:
- "2333:2333"
volumes:
- ./application.yml:/opt/Lavalink/application.yml
environment:
- _JAVA_OPTIONS=-Xmx1G
lavalink-2:
image: ghcr.io/lavalink-devs/lavalink:4
container_name: lavalink-2
ports:
- "2334:2333"
volumes:
- ./application.yml:/opt/Lavalink/application.yml
environment:
- _JAVA_OPTIONS=-Xmx1G
version: '3.8'
services:
lavalink:
image: ghcr.io/lavalink-devs/lavalink:4
networks:
- bot-network
# No ports exposed externally
discord-bot:
build: ./bot
networks:
- bot-network
environment:
- LAVALINK_HOST=lavalink
- LAVALINK_PORT=2333
networks:
bot-network:
driver: bridge
When both services are on the same Docker network:
const nodes = [{
host: 'lavalink', // Container name
port: 2333,
password: 'your_password'
}];
version: '3.8'
services:
lavalink:
image: ghcr.io/lavalink-devs/lavalink:4
ports:
- "2333:2333"
volumes:
- ./application.yml:/opt/Lavalink/application.yml
prometheus:
image: prom/prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
grafana:
image: grafana/grafana
ports:
- "3000:3000"
depends_on:
- prometheus
scrape_configs:
- job_name: 'lavalink'
static_configs:
- targets: ['lavalink:2333']
# Start
docker compose up -d
# Stop
docker compose down
# Restart
docker compose restart
# View logs
docker compose logs -f
# Check status
docker compose ps
# Pull latest image
docker compose pull
# Recreate container with new image
docker compose up -d --force-recreate
# Enter container shell
docker exec -it lavalink sh
# Check resource usage
docker stats lavalink
# Inspect container
docker inspect lavalink
Check logs for errors:
docker logs lavalink
Common causes:
Verify container is running:
docker ps
Check port mapping:
docker port lavalink
Set memory limits in docker-compose.yml and JVM options.
Docker simplifies Lavalink deployment with consistent environments and easy management. Use the production configuration for reliable operation and add monitoring for visibility into performance.
VexaNode provides managed Lavalink hosting that handles all this infrastructure, letting you focus on your music bot instead of container management.
Join thousands of satisfied users and experience the VexaNode difference today.
View Plans