docker-compose
· 891 B · Text
Brut
根据需要进行设置
$ /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
1 | 根据需要进行设置 |
2 | $ /etc/systemd/system/ |
3 | $ vim ./docker-compose-app.service |
4 | |
5 | |
6 | ```bash |
7 | [Unit] |
8 | Description=Docker Compose Application Service |
9 | Requires=/snap/bin/docker-compose |
10 | After=/snap/bin/docker-compose |
11 | |
12 | [Service] |
13 | Type=oneshot |
14 | RemainAfterExit=yes |
15 | WorkingDirectory=/home/rdf/Desktop |
16 | ExecStart=/snap/bin/docker-compose up -d |
17 | ExecStop=/snap/bin/docker-compose down |
18 | TimeoutStartSec=0 |
19 | |
20 | [Install] |
21 | WantedBy=multi-user.target |
22 | ``` |
23 | |
24 | 服务拷贝(如有需要,将该服务单元文件移动到/etc/systemd/system/目录中) |
25 | sudo mv docker-compose.service /etc/systemd/system/ |
26 | |
27 | 刷新systemd服务配置: |
28 | $ sudo systemctl daemon-reload |
29 | |
30 | 启用并启动该服务: |
31 | sudo systemctl enable docker-compose.service |
32 | sudo systemctl start docker-compose.service |
33 | |
34 | 当系统启动时,Docker Compose将自动启动您的应用程序容器 |
35 | |
36 | 打印docker-compose的程序路径 |
37 | which docker-compose |