查找Docker Hub上的php镜像

[root@localhost]# docker search php
INDEX       NAME                                                                DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/php                                                       While designed for web development, the PH...   2958      [OK]
docker.io   docker.io/richarvey/nginx-php-fpm                                   Container running Nginx + PHP-FPM capable ...   485                  [OK]
docker.io   docker.io/phpmyadmin/phpmyadmin                                     A web interface for MySQL and MariaDB.          437                  [OK]
docker.io   docker.io/eboraas/apache-php                                        PHP5 on Apache (with SSL support), built o...   133                  [OK]
docker.io   docker.io/php-zendserver                                            Zend Server - the integrated PHP applicati...   126       [OK]
docker.io   docker.io/webdevops/php-nginx                                       Nginx with PHP-FPM                              92                   [OK]
docker.io   docker.io/nazarpc/phpmyadmin                                        phpMyAdmin as Docker container, based on o...   56                   [OK]
docker.io   docker.io/phpunit/phpunit                                           PHPUnit is a programmer-oriented testing f...   50                   [OK]
docker.io   docker.io/webdevops/php-apache                                      Apache with PHP-FPM (based on webdevops/php)    50                   [OK]
docker.io   docker.io/osixia/phpldapadmin                                       phpLDAPadmin with easy configuration via e...   38
docker.io   docker.io/imagine10255/centos6-lnmp-php56                           centos6-lnmp-php56                              36                   [OK]
docker.io   docker.io/webdevops/php-apache-dev                                  PHP with Apache for Development (eg. with ...   36                   [OK]
docker.io   docker.io/tetraweb/php                                              PHP 5.5, 5.6, 7.0, 7.1 for CI and running ...   23                   [OK]
docker.io   docker.io/1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5      ubuntu-16-nginx-php-phpmyadmin-mysql-5          20                   [OK]
docker.io   docker.io/webdevops/php                                             PHP (FPM and CLI) service container             18                   [OK]
docker.io   docker.io/clinta/phpipam                                            phpIPAM web IP address management applicat...   9                    [OK]
docker.io   docker.io/phpdocker/phpdocker                                       PHP, MariaDB, Composer, PHP CodeSniffer.        7                    [OK]
docker.io   docker.io/graze/php-alpine                                          Smallish php7 alpine image with some commo...   5                    [OK]
docker.io   docker.io/antage/apache2-php5                                       Docker image for running Apache 2.x with P...   4                    [OK]
docker.io   docker.io/appsvc/php                                                Azure App Service php dockerfiles               4                    [OK]
docker.io   docker.io/lephare/php                                               PHP container                                   4                    [OK]
docker.io   docker.io/thatsamguy/trusty-php71                                   Ubuntu Trusty PHP71                             3
docker.io   docker.io/phundament/php                                            [outdated] Phundament 4 php:cli and php:fp...   2
docker.io   docker.io/1and1internet/ubuntu-16-nginx-php-phpmyadmin-mariadb-10   ubuntu-16-nginx-php-phpmyadmin-mariadb-10       1                    [OK]
docker.io   docker.io/isotopab/php                                              Docker PHP                                      0                    [OK]

这里我们拉取官方的镜像,标签为5.6-fpm

[root@localhost]# docker pull php:5.6-fpm

等待下载完成后,我们就可以在本地镜像列表里查到REPOSITORY为php,标签为5.6-fpm的镜像。

[root@localhost]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/php       5.6-fpm             243143820004        32 hours ago        368.2 MB
docker.io/centos    latest              3fa822599e10        3 weeks ago         203.5 MB

[root@localhost]# docker run -p 9002:9000 --name  myphp-fpm -v /data/www/tipask-3.2.1:/data/www/tipask-3.2.1 -v $PWD/conf:/usr/local/etc/php -v $PWD/logs:/phplogs   -d php:5.6-fpm

命令说明:

-p 9002:9000 :将容器的9002端口映射到主机的9000端口

–name myphp-fpm :将容器命名为myphp-fpm

-v ~/nginx/www:/www :将主机中项目的目录www挂载到容器的/www

-v $PWD/conf:/usr/local/etc/php :将主机中当前目录下的conf目录挂载到容器的/usr/local/etc/php

-v $PWD/logs:/phplogs :将主机中当前目录下的logs目录挂载到容器的/phplogs

查看容器启动情况

[root@localhost]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
f0fe2d2d2eef        php:5.6-fpm         "docker-php-entrypoin"   2 hours ago         Up 2 hours          0.0.0.0:9002->9000/tcp   myphp-fpm

通过浏览器访问phpinfo()

这里写图片描述

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐