【问题标题】:Docker - nginx with mounted host volume hangs using docker-composeDocker - 使用 docker-compose 挂载主机卷的 nginx 挂起
【发布时间】:2019-04-10 06:52:19
【问题描述】:

我是 Docker 新手,在设置简单文件服务器时遇到问题。我的目标是将主机卷 (Windows) 链接到来宾 Linux VM。

问题是在运行docker-compose up 后,控制台挂起并显示标准输出“附加到 docker_web_1”。

我有三个主要文件和一个文件夹,即服务器“web”的根目录,我需要将它们附加到 Linux VM。

docker-compose.yml:

web:
  image: nginx
  volumes:
   - C:/docker/web:/usr/share/nginx/html/
  ports:
   - "8080:80"

Dockerfile:

FROM nginx:latest
COPY nginx.conf /etc/nginx/nginx.conf`

nginx.conf:

worker_processes 1;

events { worker_connections 1024; }

http {
    sendfile on;
    server {
        root /usr/share/nginx/html/;
        index index.html;
        server_name localhost;
        listen 80;
    }
}

谁能帮我设置这个服务器?

【问题讨论】:

    标签: docker nginx docker-compose dockerfile docker-container


    【解决方案1】:

    这是意料之中的,附加意味着您的控制台与容器的标准输出和标准错误“链接”。

    如果您访问localhost:8080,您应该能够在控制台中看到日志。

    如果您不想要日志,请改用docker-compose up -d,-d 表示detached。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-19
      • 2017-06-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多