自学内容网 自学内容网

dockerfile实现lnmp

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

 

结果

 

 

 


原文地址:https://blog.csdn.net/2401_87121330/article/details/145147774

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!