背景:
为了方便整体产品的发布,希望通过docker实现增量发布。大致的思路如下:
is-there-a-way-to-add-only-changed-files-to-a-docker-image-as-a-new-layer-with。本博文对这种方式进行了尝试,与此同时简单介绍如何通过Dockerfile来创建Docker镜像。
前期准备:
- 解决centos的网络问题【can not find a valid baseurl for repo: base/7/x86_64】,使用dhclient命令
http://stackoverflow.com/questions/30424860/yum-error-centos-7-1-x86-64 - 解决下载docker官方镜像问题【Docker - dial tcp: lookup index.docker.io: no such host - Solution】,解决方案:https://linuxconfig.org/docker-dial-tcp-lookup-index-docker-io-no-such-host-fix
- centos命令行中解析json串。【How to parse JSON string via command line on Linux】,使用一个开源库,详情参考:http://xmodulo.com/how-to-parse-json-string-via-command-line-on-linux.html
【备注】:建议在windows下先下载jq库,然后再使用pscp等工具上传到linux中,我在多款linux系统下尝试使用wget直接下载,速度卡的要死。
docker镜像和容器再学习:
1. docker image
官方的解释:
- 镜像:An image is a filesystem and parameters to use at runtime. It doesn’t have state and never changes.
- 容器:A container is a running instance of an image.
- 引擎:When you ran the command, Docker Engine:
(1)checked to see if you had the hello-world software image;
(2)downloaded the image from the Docker Hub (more about the hub later);
(3)loaded the image into the container and “ran” it
我们之所以使用docker,就如同他的logo中的集装箱一样:通过docker镜像来创建和