centos8制作nginx-php镜像

一、安装docker

[root@host01 ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[root@host01 ~]# yum install -y docker-ce
[root@host01 ~]# docker --version
Docker version 19.03.11, build 42e35e61f3

二、搜索官方镜像并下载

#OFFICIAL是官方镜像  
[root@host01 ~]# docker search centos
NAME                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
centos                             The official build of CentOS.                   6078                [OK]                
ansible/centos7-ansible            Ansible on Centos7                              131                                     [OK]
consol/centos-xfce-vnc             Centos container with "headless" VNC session…   117                                     [OK]
jdeathe/centos-ssh                 OpenSSH / Supervisor / EPEL/IUS/SCL Repos - …   115                                     [OK]
centos/systemd                     systemd enabled base container.                 85                                      [OK]
centos/mysql-57-centos7            MySQL 5.7 SQL database server                   77                                      
imagine10255/centos6-lnmp-php56    centos6-lnmp-php56                              58                                      [OK]
tutum/centos                       Simple CentOS docker image with SSH access      47                                      
centos/postgresql-96-centos7       PostgreSQL is an advanced Object-Relational …   46                                      
kinogmt/centos-ssh                 CentOS with SSH                                 29                                      [OK]
pivotaldata/centos-gpdb-dev        CentOS image for GPDB development. Tag names…   12                                      
guyton/centos6                     From official centos6 container with full up…   10                                      [OK]
centos/tools                       Docker image that has systems administration…   6                                       [OK]
drecom/centos-ruby                 centos ruby                                     6                                       [OK]
pivotaldata/centos                 Base centos, freshened up a little with a Do…   4                                       
darksheer/centos                   Base Centos Image -- Updated hourly             3                                       [OK]
pivotaldata/centos-gcc-toolchain   CentOS with a toolchain, but unaffiliated wi…   3                                       
pivotaldata/centos-mingw           Using the mingw toolchain to cross-compile t…   3                                       
miko2u/centos6                     CentOS6 日本語環境                                   2                                       [OK]
blacklabelops/centos               CentOS Base Image! Built and Updates Daily!     1                                       [OK]
indigo/centos-maven                Vanilla CentOS 7 with Oracle Java Developmen…   1                                       [OK]
mcnaughton/centos-base             centos base image                               1                                       [OK]
pivotaldata/centos6.8-dev          CentosOS 6.8 image for GPDB development         0                                       
smartentry/centos                  centos with smartentry                          0                                       [OK]
pivotaldata/centos7-dev            CentosOS 7 image for GPDB development           0     
#拉取基础镜像
[root@host01 ~]# docker pull centos   
[root@host01 ~]# docker images   
centos              latest              831691599b88        2 weeks ago         215MB    
[root@host01 ~]# # mkdir -p 2222/docker_demo   
[root@host01 docker_demo]# ls
Dockerfile  index.php  nginx-1.19.0.tar.gz  nginx.conf  php-7.4.7.tar.gz  php-fpm  run.sh   
#nginx-1.19.0.tar.gz     php-7.4.7.tar.gz   官网下载包
#php-fpm  启动php脚本 run.sh  启动其他程序脚本
#index.php 做测试        nginx.conf 修改好的nginx配置文件       Dockerfile 制作docker镜像

三、开始制作镜像

[root@host01 docker_demo]# docker build -t centos_nginx:v1 -f Dockerfile .  
Sending build context to Docker daemon  17.65MB
Step 1/22 : FROM centos:latest
......
.....
Successfully built e937d279cf38
Successfully tagged centos_nginx:v1
#镜像制作成功
[root@host01 docker_demo]# docker images
centos_nginx        v1                  e937d279cf38        54 minutes ago      1.43GB

四、开始验证镜像是否达到预期效果

[root@host01 docker_demo]# docker run -it -p 60:80 centos_nginx:v1
Starting php-fpm daemon is succes

1、nginx成功并且已启动

在这里插入图片描述

2、php已成功启动

在这里插入图片描述

五、打包镜像

[root@host01 ~]# docker images
centos_nginx        v1                  e937d279cf38        About an hour ago   1.43GB
[root@host01 ~]# docker save -o docker.io-centos-nginx-php.tar centos_nginx:v1
[root@host01 ~]# ls docker.io-centos-nginx-php.tar 
docker.io-centos-nginx-php.tar

六、制作过程中遇到的错误

1、error: Package requirements (oniguruma) were not met
解决办法:wget http://mirror.centos.org/altarch/8/PowerTools/armhfp/os/Packages/oniguruma-devel-6.8.2-1.el8.armv7hl.rpm && dnf --enablerepo=PowerTools install oniguruma-devel -y

2、configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
yum install libsqlite3x-devel -y

3、Error: Unable to find a match: RUN install /bin/sh: line 0: cd: too many arguments
编译时语法错误,请仔细检查

4、make: No targets specified and no makefile found. Stop.
解决办法 yum install make automake -y

5、nginx: [error] invalid PID number
解决办法:/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值