Docker Community Forums

Share and learn in the Docker community.

Docker-compose up doesn't work because `Nginx failed to build`. Don't know how to fix

I’m new to docker, and have been trying to troubleshoot this error for a while. I’ve read similar posts and nothing seems to work.

Full error:

failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to copy: httpReadSeeker: failed open: could not fetch content descriptor sha256:eff196a3849ad6541fd3afe676113896be214753740e567575bb562986bd2cd4 (application/vnd.docker.distribution.manifest.v1+json) from remote: not found
ERROR: Service 'nginx' failed to build : Build failed 

I have three Dockerfiles, one for my react frontend, one for my django backend, and one for nginx.

Frontend dockerfile:

COPY ./react_app/package.json .
RUN apk add --no-cache --virtual .gyp \
        python \
        make \
        g++ \
    && npm install \
    && apk del .gyp

COPY ./react_app .

ARG API_SERVER
ENV REACT_APP_API_SERVER=${API_SERVER}
RUN REACT_APP_API_SERVER=${API_SERVER} \ 
  npm run build

WORKDIR /usr/src/app
RUN npm install -g serve
COPY --from=builder /usr/src/app/build ./build

Django Python backend Dockerfile

WORKDIR /usr/src/app

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY ./requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt

FROM python:3.7.9-slim-stretch
RUN apt-get update && apt-get install -y --no-install-recommends netcat && \
   apt-get autoremove -y && \
   apt-get clean && \
   rm -rf /var/lib/apt/lists/*

COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
RUN pip install --no-cache /wheels/*
WORKDIR /usr/src/app
COPY ./entrypoint.sh /usr/src/app/entrypoint.sh

COPY ./django_app .

RUN chmod +x /usr/src/app/entrypoint.sh
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]

and the nginx dockerfile

FROM nginx:1.19.0-alpine

RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d

WORKDIR /usr/src/app

I don’t know where to go from here. I’ve tried following 5 or 6 similar stack overflows and many more github issues, to no avail. Thanks, please let me know.

Good morning,

first thing that come to my mind is that the first two Dockerfiles are missing a FROM so docker does not know where (=which base-image) to copy the files to.

Hi, and good morning. Do you know of a good example of this? I have a FROM python:3.7.9-slim-stretch but I’m assuming you’re referring to something different.

Hello,

documentation at Dockerfile reference states that FROM is the first command in a Dockerfile (in some cases prepended by ARG) - but may appears again later if you are doing a multi-stage-build.

Also the COPY --from=... looks strange as it tries to copy data from a previous build-stage named builder which would be initiated with FROM ... AS builder.

Additional your line ARG API_SERVER looks different than in documentation where a value is assigned to a variable and used later with ${...} or $... (see Dockerfile reference) - but not in the Frontend dockerfile.

So either something was lost during copy & paste for the first and second Dockerfile or it can’t work as you first have to set the stage with FROM before doing some COPY, RUN, …

Okay, thank you. I tried copy & pasting the exact code again from the GitHub, to no avail. & Don’t I have FROM at the start of both documents? Or do you need a FROM for each process you do in a Dockerfile? If so, would I need to use another FROM node:12.18.3-alpine3.9 as builder before I copy the react project and perform the Npm build?

Yes - every Dockerfile needs a FROM

I would guess: Yes