Making Mirrors
1. Download CentOS image
Docker Pull Centos:latest
CentOS version of download is 7.3
2. Start a container by CentOS mirroring
Docker Run-i-T Centos/bin/bash
3. Install the required environment in the container
Reference: Install PHP environment under CentOS 7.x
# Update Source
RPM-UVH https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RPM-UVH https:// mirror.webtatic.com/yum/el7/webtatic-release.rpm
# Install PHP
yum install php56w php56w-opcache php56w-fpm php56w-gd php56w-mysql php56w-gd php56w-snmp php56w-xml php56w-i Map Php56w-ldap php56w-mbstring
# after the installation is complete, view the installed PHP [root@iz941fxzd86z ~]# yum list installed | grep php php56w.x86_64 5.6.30-1.w6 @webtatic php56w-cli.x86_64 5.6.30-1.w6 @webtatic Php56w-common
. x86_64 5.6.30-1.w6 @webtatic php56w-fpm.x86_64 5.6.30-1.w6 @webtatic php56w-gd.x86_64 5.6.30-1.w6 @webtatic php56w-imap.x86_64 5.6.30-1.w6 @webtatic php56w-ldap.x86_64 5.6.30-1.w6 @webtatic php56w-mbstring.x86_64 5.6.30-1.w6 @webtatic php56w-mysql.x86_64 5.6.30-1.w6 @webtatic php56w-opcache.x86_64 5.6.30-1.w6 @webtatic php56w-pdo.x86_64 5.6.30-1.w6 @webtatic php56w-snmp . x86_64 5.6.30-1.w6 @webtatic php56w-xml.x86_64 5.6.30-1.w6 @webtat IC
# install Nginx
Yum install Nginx
# config Nginx
# Plan map to external directory for/data
#/data/conf directory store nginx profile
#/data/log directory store nginx log
# PHP project path is/data
VI nginx.conf
# add include/data/conf/*.conf;
4. Submit Mirror "Submit container as mirror"
Docker commit 386e Dhshen/php_env
The mirror to this step is produced, can be used directly, but we can push the mirror to Docker.hub, so that the next time on other computers to download the direct use on it. Of course, the mirror on the push is open and everyone can download it.
5. Push Mirror to Dockerhub
Docker Push Dhshen/php_env
[Of course, first have to go to Docker.io registered account, similar to GitHub, first have to have a landing process, here skip] Start Container
1. Download image (if the image is made locally, you do not have to download it)
Docker Pull Dhshen/php_env
When the download is complete, use the following command to view the mirror
Docker images
2. Run the container
Docker run-d-P 80:80--name my_php_env-it-v/users/admin/phpstormprojects:/data Dhshen/php_env/bin/bash
Maps the local 80 port to the container's 80 port, mapping the local/users/admin/phpstormprojects directory to the container's/data directory.
Create a conf and log file under/users/admin/phpstormprojects, one to put the Nginx configuration file, and the other to hold the Nginx log.
Create local.conf in the Conf directory, example for the CI framework PHP application.
server{
Listen;
server_name localhost;
Index index.php index.html index.htm;
Error_log/data/log/err.log;
Access_log/data/log/access.log;
Location/{
root/data/example;
Try_files $uri $uri//example/index.php $query _string
}
Location ~ \.php ($|/) {
root/data/example;
Include Fastcgi_params;
Fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass Unix:/tmp/php-cgi.sock;
Fastcgi_index index.php;
Include fastcgi.conf;
Fastcgi_split_path_info ^ (. +\.php) (. *) $;
Fastcgi_param path_info $fastcgi _path_info;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Fastcgi_param ci_env ' development ';
}
3. Enter the container to start Nginx and PHP-FPM
Docker exec-i-T Df5e/bin/bash
# nginx #
/usr/sbin/php-fpm
# exit
4. Enter localhost in the browser, if you see the CI frame Welcome page, all OK.