This README provides instructions for setting up Docker services to start automatically when using profiles within an LXC container.
To start services with Docker Compose using profiles:
docker compose --profile profilename up -dOr to rebuild and start:
docker compose --profile profilename up -d --build --remove-orphans- arrs
- dns1
- dns2
- monitoring
- npm
- plex
- downloads
- portainer
- all
⚠️ NO LONGER NEEDED: No longer running Plex in an LXC inside of a container because of hardware transcoding issues. Can still use this as a reference for other LXCs.
To ensure Plex starts automatically when your LXC container boots, you can use the following systemd service file. Here's how to configure it:
Open the service file for editing:
sudo nano /etc/systemd/system/plex.service[Unit]
Description=ARRS with Docker Compose Profile
Requires=docker.service
After=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/home/joe/docker
EnvironmentFile=/home/joe/docker/.env
ExecStart=/bin/bash -c 'export HOSTNAME=$(hostname); /usr/bin/docker compose --profile arrs up -d'
ExecStop=/usr/bin/docker compose --profile arrs down
User=1000
Group=1000
Restart=on-failure
RestartSec=30
[Install]
WantedBy=multi-user.target
⚠️ WIP: This is currently only working when the container is created. Need to figure this out.
In order to allow various servers to use the same .env and docker-compose files, we need to set the hostname when the system first boots in order to allow it to be used as an environment variable in Docker.
sudo nano /etc/environmentAdd the following line to /etc/environment:
HOSTNAME=$(hostname)After creating or modifying the service file, use these commands to manage it:
Reload systemd to recognize the new or modified unit file:
sudo systemctl daemon-reloadEnable the service to start on boot:
sudo systemctl enable plex.serviceStart the service:
sudo systemctl start plex.serviceStop the service:
sudo systemctl stop plex.serviceRestart the service:
sudo systemctl restart plex.serviceCheck the status of the service:
sudo systemctl status plex.serviceRemember to replace plex.service with your actual service name if it differs. This setup ensures your Docker Compose services start automatically when your LXC container boots or can be manually controlled as needed.