Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

josephpipitone/docker-homelab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto Start Docker Services at LXC Boot

This README provides instructions for setting up Docker services to start automatically when using profiles within an LXC container.

Docker Compose Commands

To start services with Docker Compose using profiles:

docker compose --profile profilename up -d

Or to rebuild and start:

docker compose --profile profilename up -d --build --remove-orphans

Available Profiles

  • arrs
  • dns1
  • dns2
  • monitoring
  • npm
  • plex
  • downloads
  • portainer
  • all

Example: Systemd Service for Plex

⚠️ 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:

Create the Service File

Open the service file for editing:

sudo nano /etc/systemd/system/plex.service

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

HOSTNAME support

⚠️ 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/environment

Add the following line to /etc/environment:

HOSTNAME=$(hostname)

Manage the Service

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-reload

Enable the service to start on boot:

sudo systemctl enable plex.service

Start the service:

sudo systemctl start plex.service

Stop the service:

sudo systemctl stop plex.service

Restart the service:

sudo systemctl restart plex.service

Check the status of the service:

sudo systemctl status plex.service

Remember 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.

About

HomeLab - Docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published