Docker 镜像
一、容器转镜像
1docker commit <containerId> <image:tag>
2docker commit 3ffa4284ddca zookeeper:3.4.14
二、镜像保存文件
docker save zookeeper:3.4.14 > zookeeper_3.4.14.tar.gz
三、Dockerfile参考
1FROM openjdk:8-jre
2MAINTAINER songxz
3WORKDIR /appADD ./ /app/ENV JAVA_OPTS "-Xms400m -Xmx3g"ENV spring.profiles.active prod
4ENV file.encoding UTF-8EXPOSE 8089EXPOSE 20889RUN chmod 777 /app/start.shENTRYPOINT ["/app/start.sh"]
四、Dockerfile编译镜像
1docker build -f ./Dockerfile -t 127.0.0.1:2000/web:v20190416184152
2docker 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
1version: '3.1'
2services:
3 vpcs:
4 image: 127.0.0.1:2000/web:v20190416184152
5 deploy:
6 replicas: 5
7 resources:
8 limits:
9 cpus: "1"
10 memory: 8G
11 restart_policy:
12 condition: on-failure
13 placement:
14 constraints:
15 - node.labels.usage==web_vpc
16 ports:
17 - 8085:8085
18 - 20885:20885
19 environment:
20 DUBBO_IP_TO_REGISTRY: 127.0.0.1
21 DUBBO_PORT_TO_REGISTRY: 20885
22 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