docker run -p 3306:3306 --name mysql56 -v /usr/local/docker/mysql56/conf:/etc/mysql/conf.d -v /usr/local/docker/mysql56/logs:/logs -v /usr/local/docker/mysql56/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6 --innodb-flush-method=O_DSYNC --innodb-use-native-aio=0
docker run --name php7.1 -v /www:/var/www/html -p 9000:9000 -d --link mysql56:db php:7.1-fpm
docker run -d -p 80:80 -p81:81 -p82:82 -p83:83 -p84:84 -p85:85 -p86:86 -p87:87 -p88:88 -p89:89 -p90:90 -p91:91 -p92:92 -p93:93 -p94:94 -p95:95 -p96:96 -p97:97 -p98:98 -p99:99 --name nginx -v /www:/var/www/html -v /usr/local/docker/nginx/conf/conf.d:/etc/nginx/conf.d -v /usr/local/docker/nginx/logs:/var/log/nginx --link php7.1:php7.1 nginx
如果docker ps发现nginx未启动, 执行 su -c "setenforce 0" (临时方式关闭selinux,每次容器重启前都要执行),不要添加 --privileged=true(要不然可能有文件权限问题)
可以选择永久关闭selinux
cp /etc/selinux/config /etc/selinux/config.bak # cat /etc/selinux/config # 更改setlinux级别 sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config # ==> vim /etc/selinux/config/ --> SELINUX=permissive
[效果同上] # SELINUX参数enforcing代表打开,disabled代表关闭 # 查看selinux状态: getenforce
安装php扩展:
docker exec -it php容器id /bin/bash
使用 docker-php-ext-install pdo_mysql 进行安装
插件安装可参考:
# Notice: # 1. Mcrypt was DEPRECATED in PHP 7.1.0, and REMOVED in PHP 7.2.0. # 2. opcache requires PHP version >= 7.0.0. # 3. soap requires libxml2-dev. # 4. xml, xmlrpc, wddx require libxml2-dev and libxslt-dev. # 5. Line `&& :\` is just for better reading and do nothing. RUN apt-get update && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install gd && : && apt-get install -y libicu-dev && docker-php-ext-install intl && : && apt-get install -y libxml2-dev && apt-get install -y libxslt-dev && docker-php-ext-install soap && docker-php-ext-install xsl && docker-php-ext-install xmlrpc && docker-php-ext-install wddx && : && apt-get install -y libbz2-dev && docker-php-ext-install bz2 && : && docker-php-ext-install zip && docker-php-ext-install pcntl && docker-php-ext-install pdo_mysql && docker-php-ext-install mysqli && docker-php-ext-install mbstring && docker-php-ext-install exif && docker-php-ext-install bcmath && docker-php-ext-install calendar && docker-php-ext-install sockets && docker-php-ext-install gettext && docker-php-ext-install shmop && docker-php-ext-install sysvmsg && docker-php-ext-install sysvsem && docker-php-ext-install sysvshm && docker-php-ext-install opcache #&& docker-php-ext-install pdo_firebird #&& docker-php-ext-install pdo_dblib #&& docker-php-ext-install pdo_oci #&& docker-php-ext-install pdo_odbc #&& docker-php-ext-install pdo_pgsql #&& docker-php-ext-install pgsql #&& docker-php-ext-install oci8 #&& docker-php-ext-install odbc #&& docker-php-ext-install dba #&& docker-php-ext-install interbase #&& : #&& apt-get install -y libmcrypt-dev #&& docker-php-ext-install mcrypt #&& : #&& apt-get install -y curl #&& apt-get install -y libcurl3 #&& apt-get install -y libcurl4-openssl-dev #&& docker-php-ext-install curl #&& : #&& apt-get install -y libreadline-dev #&& docker-php-ext-install readline #&& : #&& apt-get install -y libsnmp-dev #&& apt-get install -y snmp #&& docker-php-ext-install snmp #&& : #&& apt-get install -y libpspell-dev #&& apt-get install -y aspell-en #&& docker-php-ext-install pspell #&& : #&& apt-get install -y librecode0 #&& apt-get install -y librecode-dev #&& docker-php-ext-install recode #&& : #&& apt-get install -y libtidy-dev #&& docker-php-ext-install tidy #&& : #&& apt-get install -y libgmp-dev #&& ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h #&& docker-php-ext-install gmp #&& : #&& apt-get install -y postgresql-client #&& apt-get install -y mysql-client #&& : #&& apt-get install -y libc-client-dev #&& docker-php-ext-configure imap --with-kerberos --with-imap-ssl #&& docker-php-ext-install imap #&& : #&& apt-get install -y libldb-dev #&& apt-get install -y libldap2-dev #&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu #&& docker-php-ext-install ldap