环境: CentOS 7 Linux 3.10.0-1160.el7.x86_64
具体要求如下:
(1)基于centos:6基础镜像;
(2)指定作者信息;
(3)安装httpd、mysql、mysql-server、php、php-mysql、php-gd;
(4)暴露80和3306端口;
(5)设置服务自启动。
(6)验证镜像。
步骤
[③构建 Docker 镜像](#③构建 Docker 镜像)
①创建项目目录
root@node1 \~\]# mkdir lamp \[root@node1 \~\]# cd lamp
②创建Dockerfile
root@node1 lamp\]# cat Dockerfile FROM centos:7 MAINTAINER "mysql \
" ENV WEB_DOC_ROOT="/data/web/html" RUN yum install -y httpd mariadb-server php php-msysql php-gd EXPOSE 80/tcp EXPOSE 3306/tcp CMD /bin/httpd -f -h ${WEB_DOC_ROOT}
③构建 Docker 镜像
root@node1 lamp\]# docker build -t lamp:v1.1 . ...... Successfully built 314dca356adf Successfully tagged lamp:v1.1 \[root@node1 lamp\]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE lamp v1.1 314dca356adf 2 minutes ago 633MB
④登陆到镜像仓库
root@node1 lamp\]# docker login -u admin -p Harbor12345 192.168.19.133:8081
⑤打标记并将lamp:v1.1镜像推送到远程仓库
root@node1 lamp\]# docker tag lamp:v1.1 node1:8081/test/lamp:v1.1 \[root@node1 lamp\]# docker push node1:8081/test/lamp:v1.1 The push refers to repository \[node1:8081/test/lamp
70e564259e24: Pushed
174f56854903: Pushed
v1.1: digest: sha256:ea26091cc0b09fa199915de8fd50f2cdc32705bf688891f3825793b78bee5bf1 size: 742
验证