dockerfile实现lnmp
自定义镜像实现整个架构 (基础镜像centos7)
nginx
cd /opt
mkdir nginx mysql php
vim Dockerfile

docker network create --subnet=172.111.0.0/16 mynetwork #创建自定义网段
docker run -itd --name nginx -p 80:80 --cpu-quota 20000 -m 512m -v /opt/nginx1:/usr/local/nginx/logs --network mynetwork --ip 172.111.0.10 nginx:lnmp
mysql
cd /opt/mysql
vim Dockerfile

docker run -itd --name mysql -p 3306:3306 --privileged -v /opt/mysql1:/opt/mysql --network mynetwork --ip 172.111.0.20 --cpu-quota 50000 -m 2g mysql:lnmp
docker exec -it mysql bash
mysql -u root -p
create database wordpress;
CREATE USER 'root'@'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON . TO 'root'@'%';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
CREATE USER 'wordpress'@'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'%';
flush privileges;

php
cd /opt/php
vim Dockerfile

docker run -itd --name php -p 9000:9000 --volumes-from nginx --volumes-from mysql --network mynetwork --ip 172.111.0.30 --cpu-quota 50000 -m 1g php:lnmp

结果





