集成容器打包成镜像

命令解读:
docker commit -m="描述信息" -a="作者" 容器id 目标镜像名: [TAG]

具体执行命令
docker commit -m "pig4cloud build集成环境" f399b1f1077b centos-java-node-build

hubDocker 创建Repository

远程仓储地址:https://hub.docker.com/

上传本地镜像到dockerhub

# 1、标记本地镜像,将其richpeople仓库
docker tag centos-java-node-build richpeople/centos-java-node-build

# 2、查看镜像是否标记成功
[root@oa-dev build]# docker images
REPOSITORY                          TAG        IMAGE ID       CREATED             SIZE
centos-java-node-build              latest     13b5f52c7d01   22 hours ago        1.47GB
richpeople/centos-java-node-build   latest     13b5f52c7d01   22 hours ago        1.47GB

3、推送到远程服务器 docker push richpeople/centos-java-node-build

** 这里其实还有一个步骤就是登陆远程仓储,docker login

[root@oa-dev build]# docker push richpeople/centos-java-node-build
Using default tag: latest
The push refers to repository [docker.io/richpeople/centos-java-node-build]
53f86e933596: Pushing [==================================================>]  1.283GB
174f56854903: Mounted from library/centos
53f86e933596: Pushed

latest: digest: sha256:7ef96ecd62183cb2976a38033c4f9754f5506125590e9faa3a6069d8bf99d12b size: 742

搜索容器

在本地通过docker search centos-java-node-build,如果能搜索到对应的镜像,说明我们的镜像已经上传到远程服务器上了

[root@8hqw ~]# docker search centos-java-node-build
NAME                                DESCRIPTION                          STARS     OFFICIAL   AUTOMATED
richpeople/centos-java-node-build   pig4cloud 微服务项目一键build发布,java和nod…   0

部署容器

docker-compose.yaml

version: '3'
services:
  centos-build:
    image: richpeople/centos-java-node-build
    container_name: centos-build
    stdin_open: true
    privileged: true
    volumes:
      - /data/git:/data

执行 docker-compose up -d

后续的本地脚本配置,可以参考 :

【二】pig4cloud项目一键build — 编写发布脚本