dockerfile - docker-compose mounts data volume but has no data
淡淡烟草味
淡淡烟草味 2017-05-16 13:17:20
0
1
1260

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?

淡淡烟草味
淡淡烟草味

reply all(1)
世界只因有你

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template