Dockerfile
/docker
:用于存放各种镜像的Dockerfiles
Nginx-PHP7
/docker/nginx-php7
/docker/nginx-php7/sites-available
:将容器中/etc/nginx/sites-available
配置文件拷贝到宿主机中,便于修改配置信息
/docker/nginx-php7/Dockerfile
FROM richarvey/nginx-php-fpm:latest
# 将宿主机中配置信息,拷贝到容器中
COPY ./docker/nginx-php7/sites-available /etc/nginx/sites-available
复制代码
mysql
/docker/mysql
/dacker/mysql/my.cnf
:配置文件
[mysqld]
character-set-server = utf8mb4
复制代码
/docker/mysql/Dockerfile
FROM mysql:5.7
COPY my.cnf /etc/mysql/mysql.conf.d
EXPOSE 3306
复制代码
docker-compose.yml
/docker-compose.yml
version: '3'
services:
lottery-nginx-php7:
build:
context: .
dockerfile: docker/nginx-php7/Dockerfile
container_name: lottery-nginx-php7
ports:
- 8889:80
volumes:
- ./:/var/www/html
environment:
- SKIP_COMPOSER=true
- WEBROOT=/var/www/html/public
networks:
- net1
lottery-mysql:
build: ./docker/mysql
container_name: lottery-mysql
ports:
- 3307:3306
volumes:
- data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=admin123456
restart: always
networks:
- net1
//需要配置所有容器使用一个网段,不配置会默认给分配一个
networks:
net1:
driver: bridge
//创建卷轴用于挂载mysql数据
volumes:
data:
driver: local
复制代码