Docker无法挂载Nginx [英] Docker unable to mount nginx

查看:614
本文介绍了Docker无法挂载Nginx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Docker Toolbox在Windows上首次设置Docker时遇到问题.目前,除了nginx之外,其他所有东西都可以正常工作.

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: 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配置:

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:

该问题似乎与Nginx有关,无法访问default.conf或应用程序认为它是文件夹而不是文件. 我在线检查了此问题,人们建议安装C:文件夹,因此我尝试将其安装在Oracle VirtualBox上并重新运行docker-compose up命令,但无法解决问题.

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.

有什么主意吗?

推荐答案

我解决了与Oracle VirtualBox VM default

共享您的项目文件夹,然后重新启动虚拟机.

Share your project folder and restart your vm.

您甚至可以使用如下命令 docker-machine stop default& docker-machine stop default

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

现在,您需要在撰写文件(docker-compose.yml)中使用共享名(项目)而不是.

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

对于您的情况,

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

应更改为

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

现在尝试使用docker-compose up.

对我有用.

这篇关于Docker无法挂载Nginx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆