1

I'm trying to do docker-compose build but the nginx return this error :

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

Here's the docker-compose.yml and the Dockerfile as well:

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

And the Dockerfile:

FROM nginx:latest
​
RUN rm /etc/nginx/conf.d/default.conf
​
COPY ./docker/nginx/nginx.conf /etc/nginx/conf.d/
1
  • did you pull latest image? not able to reproduce the error, also is the docker/nginx/Dockerfile same one you posted above Commented Jun 10, 2020 at 11:50

2 Answers 2

1

When copying your Dockerfile, I get:

Error response from daemon: Dockerfile parse error line 2: unknown instruction:

I think this is a problem with encoding. Try to convert your Dockerfile to UTF-8.

Sign up to request clarification or add additional context in comments.

Comments

0

Context is used to specify the location of build Dockerfile:

CONTEXT:

Either a path to a directory containing a Dockerfile, or a url to a git repository.

From the structure of your project, default.conf located inside the same directory that your Dockerfile is in.

Your Dockerfile should be like this:

FROM nginx:latest
​
RUN rm /etc/nginx/conf.d/default.conf
​
COPY ./nginx.conf /etc/nginx/conf.d/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.