前提
需要在服务器中已经安装了Docker Compose。
另外关于如何创建镜像可以看这篇文章:使用Dockerfile构建Spring Boot Jar包镜像
创建docker-compose.yml
# 指定本 yml 依从的 compose 哪个版本制定的
version: "3"
# 服务
services:
# 服务名
crawler-price:
# 镜像
image: registry.cn-shenzhen.aliyuncs.com/mallkj/crawler-price:1.1.0
# 容器名
container_name: crawler-price-1.1.0.res
# 是否重启
restart: always
# 日志设置
logging:
options:
max-size: "10m"
max-file: "10"
# 目录挂载
volumes:
# 宿主机:容器
- /data/temp:/data/log
# 端口映射
ports:
- 5633:8080
执行
docker-compose up -d
-d 表示后台执行该服务
启动成功