The following is the docker-compose.yml file
version: '3.2'
services:
nginx:
build: ./dockerfiles/nginx/
container_name: nginx-server
ports:
- "80:80"
links:
- "php-fpm"
volumes:
- wwwroot:/wwwroot
# - ./dockerfiles/nginx/conf.d:/etc/nginx/conf.d:ro
depends_on:
- redis-db
expose:
- "80"
- "6379"
- "3306"
- "9000"
command: nginx -g 'daemon off;'
mysql-db:
image: mysql:5.7
container_name: mysql-db
volumes:
- ./mysql_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: zhaojun
MYSQL_DATABASE: package_v1
MYSQL_USER: zhaojun
MYSQL_PASSWORD: zhaojun
redis-db:
build: ./dockerfiles/redis
container_name: redis-db
php-fpm:
build: ./dockerfiles/php/
container_name: php-fpm
volumes:
- ./wwwroot:/wwwroot
depends_on:
- mysql-db
- redis-db
volumes:
wwwroot:
driver: local
The project structure file is as follows:
But after running docker-compose up -d, nginx can access successfully, but I cannot access php internal files
$docker exec -it php-fpm /bin/bash
When I ls wwwroot, I found that there is no data in it, but
$docker insepct php-fpm
Mounted as follows
"Mounts": [
{
"Type": "bind",
"Source": "/d/Customer Files/WorkSpace/Php/30-going-home/wwwroot",
"Destination": "/wwwroot",
"Mode": "rw",
"RW": true,
"Propagation": ""
}
],
Why is this?
I personally feel that it is a problem using docker-machine in a windows environment.
After testing several times, I finally discovered the problem. I used docker-machine ssh to the virtual machine and found that c/users/
Then, I moved the project to this directory and tried again.
After docker-compose up, enter the php-fpm container and the file is successfully mounted.
Since I didn’t have a deep understanding of docker-machine mode before.