无法在Windows的Docker上挂载文件

时间:2018-07-05 05:03:57

标签: windows ubuntu docker mount docker-for-windows

问题是Docker无法共享文件。 但是文件夹没有任何问题。

我认为我采取了正确的步骤,但也许Windows有一些特殊的步骤?

我不知道可能的原因。

使用:

  • Windows10

  • ubuntu(Windows的bash外壳)

码头工人

Docker版本18.03.1-ce

docker-compose版本1.21.1

  • 适用于Windows的Docker

Docker --version Docker版本18.03.1-ce docker-compose版本1.21.1

我做了什么

  • 共享C盘

  • 为Windows和ubuntu docker连接Docker

  • EXPORT COMPOSE_CONVERT_WINDOWS_PATHS = 1

  • 修改主机文件

  • restert docker

  • --

处理

  1. docker volume create --name=mysql
  2. docker network create --driver bridge phalcon_nw
  3. docker-compose up --build

错误

ERROR: for php  Cannot start service php: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/home/tech/test/config/phalcon.ini\\\" to rootfs \\\"/var/lib/docker/overlay2/0066f6469bbf2b97cc4c7c61d94b6ce41edc4c8b34e87fd8fade3f0e1433f265/merged\\\" at \\\"/var/lib/docker/overlay2/0066f6469bbf2b97cc4c7c61d94b6ce41edc4c8b34e87fd8fade3f0e1433f265/merged/usr/local/etc/php/conf.d/phalcon.ini\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.

docker-compose.yml

version: '3.4'

services:
  mysql:
     restart: always
     image: mariadb:10.2
     container_name: phalcon_mariadb
    expose:
      - 3306
    environment:
      MYSQL_DATABASE: test
      MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
    volumes:
      - mysql:/var/lib/mysql

  php:
    restart: always
    build: ./
    container_name: phalcon_php
expose:
      # php-fpm
      - 9000
    environment:
      APP_ENV: 'development'
      XDEBUG_REMOTE_HOST: '172.23.0.1'
      XDEBUG_REMOTE_PORT: '9005'
      XDEBUG_IDE: 'vim'
      DB_HOST: 'mysql'
    volumes:
      - ./php:/app/php
      - ./html:/app/html
      - ./config/phalcon.ini:/usr/local/etc/php/conf.d/phalcon.ini
    depends_on:
      - mysql

  nginx:
    restart: always
    image: phalconphp/nginx:1.10
    container_name: phalcon_nginx
    expose:
      - 80
    volumes:
      - ./config/nginx.conf:/etc/nginx/conf.d/test.template
      - ./src:/app/src
      - ./html:/app/html
    environment:
      HOST_NAME: 'test.local'
      PHP_CONTAINER: 'php'
    command: >
      sh -c "envsubst \"`env | awk -F = '{printf \" $$%s\", $$1}'`\"
      < /etc/nginx/conf.d/test.template
      > /etc/nginx/conf.d/default.conf
      && nginx -g 'daemon off;'"
    depends_on:
      - php

# docker volume create --name=mysql
volumes:
  mysql:
    external: true

# docker network create --driver bridge phalcon_nw
# Add nginx ip to hosts with alias test.local
#     $ docker network inspect phalcon_nw | jq '.[0].Containers[] |
#         select(.Name=="phalcon_nginx") | .IPv4Address[:-3]'
networks:
  default:
    external:
      name: phalcon_nw

0 个答案:

没有答案