我正在尝试进行docker-compose构建,但是nginx返回此错误:
rm: cannot remove '/etc/nginx/conf.d/default.conf': No such file or directory
ERROR: Service 'nginx' failed to build: The command '/bin/sh -c rm /etc/nginx/conf.d/default.conf' returned a non-zero code: 1
还有docker-compose.yml和Dockerfile:
version: '3'
volumes:
pgdata:
services:
python:
build:
context: .
dockerfile: docker/python/Dockerfile
environment:
- DJANGO_SETTINGS_MODULE=sphinx_django.settings.prod
ports:
- 8000:8000
depends_on:
- db
command: gunicorn -w 4 sphinx_django.wsgi:application -b 0.0.0.0:8000
db:
image: postgres:10.3
restart: always
environment:
POSTGRES_USER: '121211'
POSTGRES_HOST: db
POSTGRES_PASS: '55555'
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- "5432:5432"
nginx:
build:
context: .
dockerfile: docker/nginx/Dockerfile
restart: always
ports:
- 8080:80
depends_on:
- python
和Dockerfile:
FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf
COPY ./docker/nginx/nginx.conf /etc/nginx/conf.d/
答案 0 :(得分:1)
复制您的Dockerfile
时,我得到:
Error response from daemon: Dockerfile parse error line 2: unknown instruction:
我认为这是编码问题。尝试将Dockerfile转换为UTF-8。
答案 1 :(得分:0)
Context用于指定构建Dockerfile
的位置:
上下文:
包含Dockerfile的目录的路径或url 到git仓库。
根据项目的结构,default.conf
位于Dockerfile
所在的目录内。
您的Dockerfile应该是这样的:
FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf
COPY ./nginx.conf /etc/nginx/conf.d/