0
我的本地文件夹看起来像这样:为什么我必须要使用卷指令泊坞窗,构成
docker-compose.yml
\nginx-proxy
\code
index.html
nginx.conf
Dockerfile
index.html
包含纯HTML代码。 nginx.conf
包含这个简单的配置:
worker_processes 1;
events {
worker_connections 1024;
}
http {
sendfile on;
server {
listent 80;
root /code;
index index.html;
}
}
Dockerfile
包含这些指令:
FROM nginx:latest
COPY nginx.conf /etc/nginx/nginx.conf
COPY ./code /code
最后docker-compose
包含这些指令:
nginx:
build: ./nginx-proxy
container_name: nginx-proxy
ports:
- "8181:80"
当我运行docker-compose up
,去localhost:8181
出于某种原因我看到一个欢迎的nginx页面(不是我的index.html),但是,如果我sl ightly改变搬运工,compose.yml:
nginx:
build: ./nginx-proxy
container_name: nginx-proxy
ports:
- "8181:80"
volumes:
- ./nginx-proxy/code:/code
- ./nginx-proxy/nginx.conf:/etc/nginx/nginx.conf
所以,我的问题是,为什么我必须指定此volumes
说明?我希望我可以在COPY指令中使用我的Dockerfile。
谢谢!这是否意味着整个问题出现在这个“背景”关键词中?如果我添加并删除卷,它是否会以没有上下文和卷的相同方式工作? – Jacobian
对,应该是这样。从概念上说,你做了/认为恰到好处 –
谢谢!我会在一分钟内检查它! – Jacobian