Docker unable to mount nginx

穿精又带淫゛_ 提交于 2020-01-05 12:57:21

问题


I'm having issues setting up Docker for the first time on a Windows using the Docker Toolbox. Everything works except nginx at the moment.

Error message:

ERROR: for web  Cannot start service web: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/c/wamp64/www/cathaypacific_career/ops/nginx/default.conf\\\" to rootfs \\\"/mnt/sda1/var/lib/docker/aufs/mnt/ff9b27a89b26b0e9091264d04d3a475f18469db3cf3be473c005e2d4c7d4b5ef\\\" at \\\"/mnt/sda1/var/lib/docker/aufs/mnt/ff9b27a89b26b0e9091264d04d3a475f18469db3cf3be473c005e2d4c7d4b5ef/etc/nginx/conf.d/default.conf\\\" 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 config:

version: '3'

services:
  web:
    container_name: web
    image: nginx:1.13.3-alpine
    networks:
      - web_tier
    ports:
      - 80:80
    volumes:
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
      - ../:/code
      - /code/ops/
    depends_on:
      - app
  app:
    container_name: app
    build: ./php/
    networks:
      - web_tier
      - app_tier
    expose:
      - '9000'
    volumes:
      - ./php/settings.conf:/usr/local/etc/php-fpm.d/settings.conf
      - ../:/code
      - /code/ops/
    working_dir: /code
    entrypoint: "/bin/sh -c"
    command:
      - "php-fpm"
    env_file: ../.env
    depends_on:
      - db
  db:
    container_name: db
    image: mysql:5.6.39
    networks:
      - app_tier
      - db_tier
    expose:
      - '3306'
    ports:
      - 3306:3306
    volumes:
       - db_data:/var/lib/mysql
       - ./db:/etc/mysql/conf.d
    restart: always
    env_file: ../.env
networks:
  web_tier:
    driver: bridge
  app_tier:
    driver: bridge
  db_tier:
    driver: bridge

volumes:
  db_data:

The issue seems to be related to Nginx with the default.conf not being accessible or the app thinkgs it's a folder and not a file. I checked the issue online and people suggests to mount the C: folder so I tried to mount it on Oracle VirtualBox and re-run the docker-compose up command but it didn't solve the issue.

Any idea?


回答1:


I solved same problem with sharing folder with Oracle VirtualBox VM default

Share your project folder and restart your vm.

You can do even with command like docker-machine stop default & docker-machine stop default

Now, you need to use shared name (project) instead of . in your compose file (docker-compose.yml)

For your case,

- ./nginx/default.conf:/etc/nginx/conf.d/default.conf

should changed to

- /sharename/nginx/default.conf:/etc/nginx/conf.d/default.conf

Now try with docker-compose up.

It worked for me.



来源:https://stackoverflow.com/questions/49889896/docker-unable-to-mount-nginx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!