Docker 制作基础镜像并发布

╰半夏微凉° 2022-12-11 12:19 251阅读 0赞

Docker 制作基础镜像并发布

1.最基础的Linux系统busybox(瑞士军刀)

参考这篇文章

2. centos的基础镜像

docker官网获取你所需要的centos版本

下面以centos7示例

pull镜像

docker pull centos:7

生成容器并进入镜像

docker run --name centos7 docker.io/centos:7 bash

  • --name: 对容器命名

定制自己需要的服务

以python3.7 和nginx为例

需要安装的工具wgetmakegcc

  1. yum -y install wget make gcc

python3源码安装

  1. 1. wget 下载源码
  2. 2. configure 配置
  3. 3. make && make install 测试并编译
  4. 4. ln -s 注册软连接

参考

nginx源码安装同理

参考

删除下载的文件、安装工具

提交修改的镜像

docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

  1. OPTIONS说明
  2. -a : 提交的镜像作者
  3. -m : 提交时的说明文字
  4. -p : commit时,将容器暂停
  5. CONTAINER : 容器(一般用容器ID)
  6. REPOSITORY[:TAG] 打标签

示例:docker commit -m 'centos7 python3 + nginx' 容器ID centos7:base

3.发布到自己docker hub仓库

docker login 登陆

镜像打包

docker image tag [imageName] [username]/[repository]:[tag]

示例:docker image tag centos7:base chongjing001/centos7:base

镜像推送

docker image push [username]/[repository]:[tag]

示例:docker image push chongjing001/centos7:base

发表评论

表情:
评论列表 (有 0 条评论,251人围观)

还没有评论,来说两句吧...

相关阅读