根据需要进行设置 $ /etc/systemd/system/ $ vim ./docker-compose-app.service ```bash  [Unit] Description=Docker Compose Application Service Requires=/snap/bin/docker-compose After=/snap/bin/docker-compose [Service] Type=oneshot RemainAfterExit=yes WorkingDirectory=/home/rdf/Desktop ExecStart=/snap/bin/docker-compose up -d ExecStop=/snap/bin/docker-compose down TimeoutStartSec=0 [Install] WantedBy=multi-user.target ``` 服务拷贝(如有需要,将该服务单元文件移动到/etc/systemd/system/目录中) sudo mv docker-compose.service /etc/systemd/system/ 刷新systemd服务配置: $ sudo systemctl daemon-reload 启用并启动该服务: sudo systemctl enable docker-compose.service sudo systemctl start docker-compose.service 当系统启动时,Docker Compose将自动启动您的应用程序容器 打印docker-compose的程序路径 which docker-compose