DockerFile基于已有容器创建新镜像

Docker就不过多介绍了…

Yum安装

[root@localhost ~]# yum -y install docker
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker

搜索可用镜像并下拉

[root@localhost ~]# docker search centos
[root@localhost ~]# docker pull docker.io/centos:latest
Trying to pull repository docker.io/library/centos ...
latest: Pulling from docker.io/library/centos
Digest: sha256:b5e66c4651870a1ad435cd75922fe2cb943c9e973a9673822d1414824a1d0475
Status: Image is up to date for docker.io/centos:latest
[root@YCloudTest-Vip-testd01T ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/centos    latest              9f38484d220f        2 months ago        202 MB

创建新的镜像

本次只演示Nginx及PHP的DockerFile镜像创建

[root@localhost ~]# mkdir -p docker-build/nginx-build docker-build/php-build
[root@localhost ~]# cd docker-build/nginx-build/
[root@localhost nginx-build]# vim Dockerfile
        #使用镜像docker.io/centos:latest为底包
     1	FROM docker.io/centos:latest
        #作者信息
     2	MAINTAINER <jieshu.yang@ym68.cc>
        #运行指定命令
     3	RUN yum -y install gd-devel pcre-devel openssl openssl-devel
        #复制本地目录到容器中
     4	COPY nginx/ /usr/local/nginx/
        #复制本地文件到容器中
     5	COPY nginxd.sh /usr/local/bin/nginxd
        #容器启动时执行的脚本
     6	CMD /usr/local/bin/nginxd start

构建PHP镜像

docker build -t centos/php:v3.6.7
未经允许不得转载:www.ym68.cc Boring Site » DockerFile基于已有容器创建新镜像
分享到:
赞(0) 打赏

评论1

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1
    评论测试
    admin2019-06-28 19:46:57回复

欢迎访问本网站!

去投稿

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏