簡體   English   中英

在Windows 10上使用Docker無法看到文件

[英]Can't see files with Docker on Windows 10

我本周第一次嘗試使用Docker,但在Windows 10上遇到了一些麻煩。我可以在macOS上輕松設置我的環境,而在Windows 10上則不然。

我只是將WebDevops( https://github.com/webdevops/php-docker-boilerplate )中的樣板用作入門工具。 在Windows 10上,如果我沒有創建默認計算機,那么從我看到的情況來看,Docker使用MobyLinuxVM。

在我的文件夾中,該文件夾不是C:驅動器,而是另一個名為E:的文件夾(我的所有驅動器都在Docker設置中共享),如果我執行一個簡單的docker-compose up -d ,則可以使用http:// localhost:8000和PHPMyAdmin和http:// localhost:8080

現在,如果我使用HyperV驅動程序創建計算機,將其設置為默認計算機,將其激活並進行docker-compose,我仍然可以訪問PHPMyAdmin和app文件夾,但最后一個為空! 一個簡單的index.php文件不會被解釋。

要創建機器,我需要執行以下操作:

docker-machine create --driver hyperv --hyperv-virtual-switch "Primary Virtual Switch" default
docker machine env default
& "C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe" env default | Invoke-Expression

這是我的docker-compose.yml文件:

version: '2'
services:
  #######################################
  # PHP application Docker container
  #######################################
  app:
    build:
      context: .
      dockerfile: Dockerfile.development
    links:
      - mail
      - mysql
      #- postgres
      #- solr
      #- elasticsearch
      #- redis
      #- memcached
      #- ftp
    ports:
      - "8000:80"
      - "8443:443"
      - "10022:22"
    volumes:
      - ./app/:/app/
      - ./:/docker/
    volumes_from:
      - storage
    # cap and privileged needed for slowlog
    cap_add:
      - SYS_PTRACE
    privileged: true
    env_file:
      - etc/environment.yml
      - etc/environment.development.yml
    environment:
      - VIRTUAL_HOST=.app.boilerplate.docker
      - VIRTUAL_PORT=80
      - POSTFIX_RELAYHOST=[mail]:1025


  #######################################
  # MySQL server
  #######################################
  mysql:
    build:
      context: docker/mysql/
      #dockerfile: MySQL-5.5.Dockerfile
      dockerfile: MySQL-5.6.Dockerfile
      #dockerfile: MySQL-5.7.Dockerfile
      #dockerfile: MariaDB-5.5.Dockerfile
      #dockerfile: MariaDB-10.Dockerfile
      #dockerfile: Percona-5.5.Dockerfile
      #dockerfile: Percona-5.6.Dockerfile
      #dockerfile: Percona-5.7.Dockerfile
    ports:
      - 13306:3306
    volumes_from:
      - storage
    env_file:
      - etc/environment.yml
      - etc/environment.development.yml

  #######################################
  # PostgreSQL server
  #######################################
  #postgres:
  #  build:
  #    context: docker/postgres/
  #    dockerfile: Postgres-9.4.Dockerfile
  #    dockerfile: Postgres-9.5.Dockerfile
  #  ports:
  #    - 15432:5432
  #  volumes_from:
  #    - storage
  #  env_file:
  #    - etc/environment.yml
  #    - etc/environment.development.yml

  #######################################
  # Solr server
  #######################################
  #solr:
  #  build:
  #    context: docker/solr/
  #  volumes_from:
  #    - storage
  #  env_file:
  #    - etc/environment.yml
  #    - etc/environment.development.yml
  #  environment:
  #    - SOLR_STORAGE=/storage/solr/server-master/
  #    - VIRTUAL_HOST=solr.boilerplate.docker
  #    - VIRTUAL_PORT=8983

  #######################################
  # Elasticsearch
  #######################################
  #elasticsearch:
  #  build:
  #    context: docker/elasticsearch/
  #  ports:
  #    - 19200:9200
  #    - 19300:9300
  #  volumes_from:
  #    - storage
  #  env_file:
  #    - etc/environment.yml
  #    - etc/environment.development.yml
  #  environment:
  #    - VIRTUAL_HOST=elasticsearch.boilerplate.docker
  #    - VIRTUAL_PORT=9200

  #######################################
  # Redis
  #######################################
  #redis:
  #  build:
  #    context: docker/redis/
  #  volumes_from:
  #    - storage
  #  env_file:
  #    - etc/environment.yml
  #    - etc/environment.development.yml

  #######################################
  # Memcached
  #######################################
  #memcached:
  #  build:
  #    context: docker/memcached/
  #  volumes_from:
  #    - storage
  #  env_file:
  #    - etc/environment.yml
  #    - etc/environment.development.yml

  #######################################
  # Mail
  #######################################
  # Mailhog
  mail:
     image: mailhog/mailhog
   #  ports:
   #    - 8025:8025
     environment:
      - VIRTUAL_HOST=mail.boilerplate.docker
      - VIRTUAL_PORT=8025

  # Mailcatcher
  #mail:
  #  image: schickling/mailcatcher
  #  environment:
  #    - VIRTUAL_HOST=mail.boilerplate.docker
  #    - VIRTUAL_PORT=1080


  # Mailsandbox
  #mail:
  #  image: webdevops/mail-sandbox
  #  environment:
  #    - VIRTUAL_HOST=mail.boilerplate.docker
  #    - VIRTUAL_PORT=80

  #######################################
  # FTP (vsftpd)
  #######################################
  #ftp:
  #  build:
  #    context: docker/vsftpd/
  #  volumes_from:
  #    - storage
  #  volumes:
  #    - ./:/application/
  #  env_file:
  #    - etc/environment.yml
  #    - etc/environment.development.yml

  #######################################
  # phpMyAdmin
  #######################################
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    links:
      - mysql
    environment:
      - PMA_HOSTS=mysql
      - VIRTUAL_HOST=pma.boilerplate.docker
      - VIRTUAL_PORT=80
    ports:
      - "8080:80"
    volumes:
      - /sessions

  #######################################
  # Storage
  #######################################
  storage:
    build:
      context: docker/storage/
    volumes:
      - /storage

有人有建議嗎? 任何幫助將非常感激! 非常感謝!

主機到VM的卷掛載不適用於使用docker-machine創建的隨機VM。 它僅在使用Docker for Windows提供的設置時才起作用(或者,如果您在Windows上使用VirtualBox驅動程序使用Docker Toolbox,但由於在Windows 10上,因此應堅持使用Docker for Windows)。

為什么要創建更多的VM,為什么要從Windows主機將卷裝載到其中?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM