docker 打包应用程序:
1,针对经常更换的环境问题部署的一套系统
2,部署web项目(python程序)是为了项目测试使用
首先配置 centso 环境
docker pull centos
# 指定 <image id> 启动 --net=host 可以和宿主机通信
docker run --net=host -ti 9aec5c5fe4ba /bin/bash
#启动网络连接 得到一个软件包 net-tools.x86_64
yum search ifconfig
# 安装软件 net-tools.x86_64
# 可以使用 ifconfig 查看网络
yum install net-tools.x86_64
# 安装 python3.5(其他的可以视情况而定,和sentos安装相同)
wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz
cd /usr/local/Python-3.5.3
./configure
make
make install
文件上传的 容器之中
# 使用Ctrl+P+Q (退出但不停止容器)(也可以新开一个终端)
# 主机文件 copy到 容器之中 <containerId>
docker cp /home/hadoop/cpu-test b991647704dc:/home/
镜像打包与load
#使用 Ctrl+P+Q (退出但不停止容器)
# docker commit <image id> <name/version>
docker commit 4edc2d20ae7d cpu_collect
# 将 镜像打包到本地
docker save -o ./cpu_collect.tar 40c8d763e0fc
# 镜像加载(此时的REPOSITORY TAG 为空)
docker load -i ./cpu_collect.tar
# 为镜像重新命名(REPOSITORY 为 python-intel ,tar 为 latest)
docker tag 40c8d763e0fc cpu_collect