rdf ревизий этого фрагмента . К ревизии
1 file changed, 37 insertions
docker-compose(файл создан)
@@ -0,0 +1,37 @@ | |||
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 |
Новее
Позже