1.拉取官方image,如非必要,尽量拉取fpm。省事
docker pull php:7.4-fpm-alpine
alpine精简版
2.可以根据项目需要的扩展自行制作Dockfile,然后run
3.docker扩展命令
4 如果容器内安装
慢,进入容器运行
sed -i ‘s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g’ /etc/apk/repositories
切换源
以下是yml配置
version: '3'
services:
nginx:
image: nginx
container_name: nginx
restart: always
ports:
- 80:80
volumes:
- E:/docker/nginx/html:/usr/share/nginx/html
- E:/docker/nginx/conf.d:/etc/nginx/conf.d
- E:/docker/nginx/nginx.conf:/etc/nginx/nginx.conf
- E:/docker/nginx/logs:/var/log/nginx
php-fpm-7.4:
image: php:7.4-fpm-alpine
container_name: php-fpm-7.4
volumes:
- E:/docker/nginx/html:/var/www/html
links:
- mysql:mysql
mysql:
image: mysql:5.7
container_name: mysql-5.7
command: --default-authentication-plugin=mysql_native_password
ports:
- 3307:3306
environment:
MYSQL_ROOT_PASSWORD: root
volumes:
- E:/docker/mysql/data:/var/lib/mysql
主意自行修改目录和文件名称
有问题可以留言