Ubuntu 下docker 部署

安装

1
apt-get install -y docker.io nginx docker-compose 
1
2
3
4
5
6
7
8
9
10
11
systemctl start docker

systemctl enable docker


# 开机启动
systemctl enable nginx

systemctl start nginx 
systemctl stop nginx 
systemctl restart nginx

配置启动 service

1
cd etc/systemd/system/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[Unit]
Description={xxxxx}
After=network.target
After=docker.service

[Service]
Type=simple
User=root
ExecStart={where is docker-compose} up
WorkingDirectory={project}
Restart=on-failure
RestartSec=15

StandardOutput=syslog
StandardError=syslog

[Install]
WantedBy=multi-user.target
1
2
3
4
5
6
7
8
# Service 状态
systemctl status endoscope

# 启动失败 查看log
journalctl -u xxxx.service -f

# 更新xxx.service
systemctl daemon-reload