Media server compose example for Plex.
Educational example only. Review every volume path, port, and credential before you run this. Do not copy production secrets into your wiki or git repo.
_shared/.env for non-secrets, _shared/.secret for credentialsmkdir -p /path/to/docker/stacks/plex
cd /path/to/docker/stacks/plex
# paste compose.yaml below, then:
docker compose pull
docker compose up -d
---
services:
###########################################################################
## Docker Compose File: plex
## Function: plex
## Documentation:
###########################################################################
plex:
image: ghcr.io/hotio/plex
container_name: plex
hostname: plex
env_file:
- /path/to/docker/stacks/_shared/.env
- /path/to/docker/stacks/_shared/.secret
# healthcheck:
# test: curl --connect-timeout 15 --silent --show-error --fail http://127.0.0.1:32400/identity || exit 1
# interval: 1m00s
# timeout: 15s
# retries: 3
# start_period: 1m00s
environment:
- PLEX_SERVER=https://YOUR_HOST.YOUR_DOMAIN/
# PLEX_CLAIM_TOKEN and PLEX_TOKEN come from _shared/.secret via env_file
- PLEX_ADVERTISE_URL=https://YOUR_HOST.YOUR_DOMAIN:32400 #${PLEX_ADVERTISE_URL}
- PLEX_NO_AUTH_NETWORKS=
- PLEX_BETA_INSTALL= #${PLEX_BETA_INSTALL}
- VERSION=docker # Specifies the Docker version of Plex
- NVIDIA_VISIBLE_DEVICES=all # Tells the NVIDIA Container Toolkit to expose all available NVIDIA GPUs to the container
- NVIDIA_DRIVER_CAPABILITIES=all
logging:
driver: json-file
options:
max-file: ${DOCKERLOGGING_MAXFILE:-10} # Max number of log files
max-size: ${DOCKERLOGGING_MAXSIZE:-200k} # Max file size
ports:
- 32400:32400
#- 8324:8324/tcp
#- 32469:32469/tcp
#- 1900:1900/udp
#- 32410:32410/udp
#- 32412:32412/udp
#- 32413:32413/udp
#- 32414:32414/udp
volumes:
- /etc/localtime:/etc/localtime:ro
- /path/to/docker/data/plex:/config:rw
- /path/to/data/media:/data/media:rw
#- /mnt/photo:/media/photo:rw # Path to your photos, :ro for read-only :rw for read-write
devices: # optional: hardware transcoding (only with Plex Pass) uncomment this line.
- /dev/dri:/dev/dri # optional: hardware transcoding (only with Plex Pass) uncomment this line.
#- /dev/dvb:/dev/dvb # Uncomment this device for typical USB TV Tuner cards
tmpfs: # optional: enable transcoding in RAM. uncomment this line.
- /transcode # optional: enable transcoding in RAM. uncomment this line.
runtime: nvidia # Specify NVIDIA runtime for GPU access
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all # Use all available NVIDIA GPUs
capabilities: [gpu, utility, video] # Specify required capabilities
network_mode: host
restart: unless-stopped