3
respostas

"Nginx failed do build"

Quando utilizo o comando "docker-compose build" da esse erro, nao sei como resolver. Se alguem souber como resolver, erro abaixo:

"ERROR: Service 'nginx' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder805256990/public: no such file or directory"

3 respostas

Olá João Vitor, tudo bem? Você poderia fornecer mais detalhes pra gente! Como o sistema operacional que você está utilizando? O log completo da execução do comando docker-compose build? Coloca aqui também todo o seu arquivo docker-compose.yml! Pra gente entender o porque esse erro está acontecendo!

Boa tarde Jonilson Souza,

Utilizo o sistema: Linux Mint 19.3

O arquivo docker-compose.yml abaixo:

version: '3'

services:

nginx:
    build:
      dockerfile: ./nginx.dockerfile
      context: .
    image: douglasq/nginx
    container_name: nginx
    ports:  
     - "80:80"
    networks: 
     - production-network
    depends_on: 
     - "node1"
     - "node2"
     - "node3"   

mongodb:
    image: mongo
    networks: 
      - production-network   

node1:
    build:
        dockerfile: ./alura-books.dockerfile
        context: .
    image: douglasq/alura-books
    container_name: alura-books-1
    ports: 
      - 3000
    networks:
      - production-network
    depends_on: 
      - "mongodb"  

node2:
    build:
        dockerfile: ./alura-books.dockerfile
        context: .
    image: douglasq/alura-books
    container_name: alura-books-2
    ports:
      - 3000
    networks:
      - production-network  
    depends_on: 
      - "mongodb"  
node3:
    build:
        dockerfile: ./alura-books.dockerfile
        context: .
    image: douglasq/alura-books
    container_name: alura-books-3
    ports:
      - 3000
    networks: 
      - production-network
    depends_on: 
      - "mongodb"    

networks: production-network: driver: bridge


Agora o log do docker-compose:

mongodb uses an image, skipping

Building node2

Step 1/8 : FROM node:latest ---> c31fbeb964cc

Step 2/8 : LABEL Douglas Quintanilha ---> Using cache ---> 43bea02d0354

Step 3/8 : ENV NODE_ENV=development ---> Using cache ---> 792b68cd2851

Step 4/8 : COPY . /var/www ---> Using cache ---> 4ec49dd89b96

Step 5/8 : WORKDIR /var/www ---> Using cache ---> 0dd59a543885

Step 6/8 : RUN npm install ---> Using cache ---> f0773f4e9eaf

Step 7/8 : ENTRYPOINT ["npm", "start"] ---> Using cache ---> a589a651e2be

Step 8/8 : EXPOSE 3000 ---> Using cache ---> 5d92821bb9a8

Successfully built 5d92821bb9a8

Successfully tagged douglasq/alura-books:latest

Building node3

Step 1/8 : FROM node:latest ---> c31fbeb964cc

Step 2/8 : LABEL Douglas Quintanilha ---> Using cache ---> 43bea02d0354

Step 3/8 : ENV NODE_ENV=development ---> Using cache ---> 792b68cd2851

Step 4/8 : COPY . /var/www ---> Using cache ---> 4ec49dd89b96

Step 5/8 : WORKDIR /var/www ---> Using cache ---> 0dd59a543885

Step 6/8 : RUN npm install ---> Using cache ---> f0773f4e9eaf

Step 7/8 : ENTRYPOINT ["npm", "start"] ---> Using cache ---> a589a651e2be

Step 8/8 : EXPOSE 3000 ---> Using cache ---> 5d92821bb9a8

Successfully built 5d92821bb9a8

Successfully tagged douglasq/alura-books:latest

Building node1

Step 1/8 : FROM node:latest ---> c31fbeb964cc

Step 2/8 : LABEL Douglas Quintanilha ---> Using cache ---> 43bea02d0354

Step 3/8 : ENV NODE_ENV=development ---> Using cache ---> 792b68cd2851

Step 4/8 : COPY . /var/www ---> Using cache ---> 4ec49dd89b96

Step 5/8 : WORKDIR /var/www ---> Using cache ---> 0dd59a543885

Step 6/8 : RUN npm install ---> Using cache ---> f0773f4e9eaf

Step 7/8 : ENTRYPOINT ["npm", "start"] ---> Using cache ---> a589a651e2be

Step 8/8 : EXPOSE 3000 ---> Using cache ---> 5d92821bb9a8

Successfully built 5d92821bb9a8

Successfully tagged douglasq/alura-books:latest

Building nginx

Step 1/8 : FROM nginx:latest ---> ed21b7a8aee9

Step 2/8 : LABEL key="Douglas Quintanilha" ---> Using cache ---> 9b543c56acaf

Step 3/8 : COPY /public /var/www/public ERROR: Service 'nginx' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder642644952/public: no such file or directory

João Vitor, a linha que indica onde está o dockerfile do Nginx deveria ser ./docker/nginx.dockerfile já no seu arquivo "docker-compose.yml" está apenas ./nginx.dockerfile, então muda a linha:

dockerfile: ./nginx.dockerfile

Para a seguinte:

dockerfile: ./docker/nginx.dockerfile

O inicio do arquivo deve ficar assim:

nginx:
    build:
      dockerfile: ./docker/nginx.dockerfile
      context: .

E tenta fazer o build novamente, e fala pra gente se funcionou!