apache的Dockerfile文件
##创建apache服务的dockerfile文件目录 [root@localhost ~]# mkdir apache [root@localhost ~]# cd apache/ [root@localhost apache]# mkdir files [root@localhost apache]# cd files/ ##上传源码包 [root@localhost apache]# cd files/ [root@localhost files]# ls apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.48.tar.gz ##编写dockerfile文件 [root@localhost apache]# vim Dockerfile FROM centos LABEL WAINTAINER='luochuran 1225514226@qq.com' ADD files/* /usr/local/ WORKDIR /usr/local RUN yum -y install openssl-devel pcre-devel pcre expat-devel libtool gcc gcc-c++ make which && sed -i '/$RM "$cfgfile"/d' apr-1.7.0/configure && ./apr-1.7.0/configure --prefix=/usr/local/apr && make && make install && ./apr-util-1.6.1/configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install && ./httpd-2.4.48/configure --prefix=/usr/local/apache --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork && make && make install EXPOSE 80 CMD ["/usr/local/apache/bin/apachectl","-D","FOREGROUND"] ##构建镜像 [root@localhost ~]# docker build -t 1225514226/apache apache/ Sending build context to Docker daemon 11.07MB Step 1/7 : FROM centos ---> 5d0da3dc9764 Step 2/7 : LABEL WAINTAINER='luochuran 1225514226@qq.com' ---> Using cache ---> b07711e6377c Step 3/7 : ADD files/* /usr/local/ ---> f60a20330abb Step 4/7 : WORKDIR /usr/local ---> Running in 5fe38b9fb88a Removing intermediate container 5fe38b9fb88a ---> 7bb082e4fcbf Step 5/7 : RUN yum -y install openssl-devel pcre-devel pcre expat-devel libtool gcc gcc-c++ make which && sed -i '/$RM "$cfgfile"/d' apr-1.7.0/configure && ./apr-1.7.0/configure --prefix=/usr/local/apr && make && make install && ./apr-util-1.6.1/configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install && ./httpd-2.4.48/configure --prefix=/usr/local/apache --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork && make && make install ---> Running in 296174a923e0 ·····省略部分····· make[1]: Leaving directory '/usr/local' Removing intermediate container 296174a923e0 ---> 6e3f6cd4ee37 Step 6/7 : EXPOSE 80 ---> Running in 251a17db3ede Removing intermediate container 251a17db3ede ---> 4f03dd8f2b86 Step 7/7 : CMD ["/usr/local/apache/bin/apachectl","-D","FOREGROUND"] ---> Running in 702625fb4748 Removing intermediate container 702625fb4748 ---> 5eb3dd8e7d66 Successfully built 5eb3dd8e7d66 Successfully tagged 1225514226/apache:latest [root@localhost ~]# ##查看镜像 [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE 1225514226/apache latest 5eb3dd8e7d66 2 minutes ago 700MB 1225514226/nginx v2.0 779333eb1a39 5 days ago 601MB centos latest 5d0da3dc9764 2 months ago 231MB [root@localhost ~]# ##使用新的镜像创建容器 [root@localhost ~]# docker run -d -p 80:80 --name apache 1225514226/apache 2719c466e8317ed87aa71c2a92ef5e2ebf0663d746d1cc21dec70c3202c74ea1 [root@localhost ~]# docker ps ConTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2719c466e831 1225514226/apache "/usr/local/apache/b…" 3 seconds ago Up 3 seconds 0.0.0.0:80->80/tcp, :::80->80/tcp apache [root@localhost ~]#
访问测试
上传到官方仓库
##上传镜像到网站##登录docker [root@localhost ~]# docker login Authenticating with existing credentials... WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded ##上传镜像到网站 [root@localhost ~]# docker push 1225514226/apache The push refers to repository [docker.io/1225514226/apache] e1152074ce5a: Layer already exists 63da29d0dfbc: Layer already exists 2ece98c51a08: Layer already exists 74ddd0ec08fa: Layer already exists latest: digest: sha256:bc0c20092b38575c79adb1ad8fce9f7736ffe07e6677609ae26cc4efeb646441 size: 1161
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)