标签:docke ges 文件 上传 hang jdk8 https 单机 download
#github下载地址-下载慢
curl -L https://github.com/docker/compose/releases/download/1.26.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
#高速下载地址
curl -L https://get.daocloud.io/docker/compose/releases/download/1.26.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
#给予执行权限
chmod +x /usr/local/bin/docker-compose
#查看
docer-compose -v
#卸载
rm /usr/local/bin/docker-compose
一个项目一个Dockerfile
与项目pom
文件同级,docker-compose.yml
文件与项目同级
#依赖jdk8
FROM java:8
#维护者信息
MAINTAINER duchong <1427222829@qq.com>
#系统编码
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
#容器卷
VOLUME /tmp
#拷贝jar包
COPY target/docker-demo-0.0.1-SNAPSHOT.jar /docker-demo.jar
#暴漏端口
EXPOSE 8080
#容器启动时执行
ENTRYPOINT [ "java", "-jar", "/docker-demo.jar" ]
#依赖jdk8
FROM java:8
#维护者信息
MAINTAINER duchong <1427222829@qq.com>
#系统编码
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
#容器卷
VOLUME /tmp
#拷贝jar包
COPY target/docker-demo2-0.0.1-SNAPSHOT.jar /docker-demo2.jar
#暴漏端口
EXPOSE 8080
#容器启动时执行
ENTRYPOINT [ "java", "-jar", "/docker-demo2.jar" ]
#compose 文件的版本
version: "3"
# 一个services 下面包含多个项目服务
services:
# 服务1
docker-demo:
#镜像地址
image: registry.cn-hangzhou.aliyuncs.com/duchong/demo-repo/summer_travel/docker-demo:1.0
#容器名称
container_name: docker-demo
#无论如何容器都会重启
restart: always
#映射端口
ports:
- "8080:8080"
# 服务2
docker-demo2:
#镜像地址
image: registry.cn-hangzhou.aliyuncs.com/duchong/demo-repo/summer_travel/docker-demo2:1.0
#容器名称
container_name: docker-demo2
#无论如何容器都会重启
restart: always
#映射端口
ports:
- "8081:8081"
# 服务3、4、5
项目一和项目二根据各自的Dockerfile
生成镜像,并上传到阿里云,具体怎么操作,不知道的话可以看这篇:
[使用docker插件部署应用,看完这一篇就够了](https://www.cnblogs.com/geekdc/p/13524916.html)
将2.4中的docker-compose.yml
上传到/home/context/
文件夹下
[root@vm context]# cd /home/context/
[root@vm context]# ls
docker-compose.yml
[root@vm context]# docker-compose up -d
Creating network "context_default" with the default driver
Creating docker-demo ... done
Creating docker-demo2 ... done
[root@vm context]# docker ps -a | grep docker-demo
4577bcca724d registry.cn-hangzhou.aliyuncs.com/duchong/demo-repo/summer_travel/docker-demo:1.0 "java -jar /docker-d…" 18 seconds ago Up 17 seconds 0.0.0.0:8080->8080/tcp docker-demo
5e698b122fda registry.cn-hangzhou.aliyuncs.com/duchong/demo-repo/summer_travel/docker-demo2:1.0 "java -jar /docker-d…" 18 seconds ago Up 17 seconds 8080/tcp, 0.0.0.0:8081->8081/tcp
搞定!!!
标签:docke ges 文件 上传 hang jdk8 https 单机 download
原文地址:https://www.cnblogs.com/geekdc/p/13549495.html