欢迎来到我的的博客园,祝大家学有所成,早点实现自己的人生理想。

DockerSwarm+Dubbo镜像与部署相关命令与参数

Docker 镜像

一、容器转镜像
docker commit <containerId> <image:tag>
docker commit 3ffa4284ddca zookeeper:3.4.14
二、镜像保存文件
docker save zookeeper:3.4.14 > zookeeper_3.4.14.tar.gz
三、Dockerfile参考
FROM openjdk:8-jre
MAINTAINER songxz
WORKDIR /appADD ./ /app/ENV JAVA_OPTS "-Xms400m -Xmx3g"ENV spring.profiles.active prod
ENV file.encoding UTF-8EXPOSE 8089EXPOSE 20889RUN chmod 777 /app/start.shENTRYPOINT ["/app/start.sh"]
四、Dockerfile编译镜像
docker build -f ./Dockerfile -t 127.0.0.1:2000/web:v20190416184152
docker push 127.0.0.1:2000/web:v20190416184152
五、运行镜像
docker run -t -d --name="web" -p 8085:8085 -p 20885:20885 -e "DUBBO_IP_TO_REGISTRY=127.0.0.1" -e "DUBBO_PORT_TO_REGISTRY=20885"  -e "DUBBO_PORT_TO_BIND=20885" 127.0.0.1:2000/web:v20190416184152
六、Stack
version: '3.1'
services:
  vpcs:
    image: 127.0.0.1:2000/web:v20190416184152 
    deploy:
      replicas: 5
      resources:
        limits: 
          cpus: "1"
          memory: 8G
      restart_policy:
        condition: on-failure
      placement:
        constraints:
          - node.labels.usage==web_vpc
    ports:
      - 8085:8085
      - 20885:20885
    environment:
      DUBBO_IP_TO_REGISTRY: 127.0.0.1
      DUBBO_PORT_TO_REGISTRY: 20885
      DUBBO_PORT_TO_BIND: 20885

 

 
七、镜像打标签
docker tag web:v20190416184152 127.0.0.1:2000/web:v20190416184152
八、镜像推送
docker push 127.0.0.1:2000/web:v20190416184152
posted @ 2019-04-24 14:00  宋兴柱  阅读(586)  评论(0编辑  收藏