1、获取docker镜像
2、创建nginx容器
vim /opt/nginx/Dockerfile
vim /opt/nginx/nginx.conf
创建nginx镜像(注意最后有个点,不可省略)
docker build -t nginx:lnmp .
docker images
启动nginx容器并且为容器指定IP地址
docker run -d --name nginx -p 80:80 -m 500m --memory-swap 1g --ip 172.17.0.2 nginx:lnmp
3、创建mysql容器
vim /opt/mysql/Dockerfile
vim /opt/mysql/my.cnf
生成mysql镜像文件并启动镜像容器(需要在对应目录中完成)
docker build -t mysql:lnmp .
docker run --name=mysql -d --privileged --device-write-bps /dev/sda:10M -v /usr/local/mysql --ip 172.17.0.3 mysql:lnmp
4、创建php容器
vim /opt/php/Dockerfile
vim /opt/php/php.ini
vim /opt/php/www.conf
vim /opt/php/php-fpm.conf
构建php容器镜像
docker build -t php:lnmp .
docker images
根据php镜像创建容器并启动
docker run -itd --name php --ip 172.17.0.4 -p 9000:9000 --volumes-from nginx --volumes-from mysql php:lnmp