Seafile Docker autostart¶
You can use one of the following methods to start Seafile container on system bootup.
Modify docker-compose.service¶
-
Add
docker-compose.service
vim /etc/systemd/system/docker-compose.service
[Unit] Description=Docker Compose Application Service Requires=docker.service After=docker.service [Service] Type=forking RemainAfterExit=yes WorkingDirectory=/opt/ ExecStart=/usr/bin/docker compose up -d ExecStop=/usr/bin/docker compose down TimeoutStartSec=0 [Install] WantedBy=multi-user.target
Note
WorkingDirectory
is the absolute path to theseafile-server.yml
file directory. -
Set the
docker-compose.service
file to 644 permissionschmod 644 /etc/systemd/system/docker-compose.service
-
Load autostart configuration
systemctl daemon-reload systemctl enable docker-compose.service
Modify Docker files¶
Add configuration restart: unless-stopped
for each container in components of Seafile docker. Take seafile-server.yml
for example
services:
db:
image: mariadb:10.11
container_name: seafile-mysql-1
restart: unless-stopped
memcached:
image: memcached:1.6.18
container_name: seafile-memcached
restart: unless-stopped
elasticsearch:
image: elasticsearch:8.6.2
container_name: seafile-elasticsearch
restart: unless-stopped
seafile:
image: seafileltd/seafile-pro-mc:12.0-latest
container_name: seafile
restart: unless-stopped
Tip
Add restart: unless-stopped
, and the Seafile container will automatically start when Docker starts. If the Seafile container does not exist (execute docker compose down), the container will not start automatically.