There is a docker-compose.yaml version: '2' services:

nginx: build: nginx container_name: nginx ports: - 80:80 - 443:443 volumes: - ./:/usr/share/nginx/html php-fpm: image: nanoninja/php-fpm container_name: php-fpm volumes: - ./:/usr/share/nginx/html db: container_name: mysql image: mysql restart: always environment: - MYSQL_DATABASE=test - MYSQL_ROOT_PASSWORD=test - MYSQL_USER=test - MYSQL_PASSWORD=test phpmyadmin: container_name: phpmyadmin image: phpmyadmin/phpmyadmin links: - db ports: - 8080:80 frontend: build: frontend container_name: frontend volumes: - ./:/usr/share/frontend 

Here to the docker container file

  FROM node RUN mkdir /usr/share/frontend WORKDIR /usr/share/frontend COPY package.json /usr/share/frontend/package.json RUN npm install CMD ["npm","start"] 

At step 4 produces the following error:

Step 4/7: COPY package.json /usr/share/frontend/package.json ERROR: Service 'frontend' failed to build: lstat package.json: no such file or directory

  • Please click edit question and add your TEXT settings. - Senior Pomidor
  • in fact, you need to move the Dockerfile to the root of the project next to package.json. And the problem arises from the fact that you are relative to the folder where the Dockerfile is trying to copy the package.json file, which is actually 2 levels higher - Senior Pomidor
  • @SeniorPomidor, moved to the root of the project and now such a mistake ~ / docker $ docker-compose up -d --build ERROR: build path / home / vitaly / docker / frontend it’s not URL. - Vitaly Shonov
  • @SeniorPomidor, tell me - Vitaly Shonov February

1 answer 1

Fix COPY - COPY package.json* /usr/share/frontend/ . * - needed for package-lock.json . And read carefully about the build directive .

 build: frontend # это директория root для сборки 

need to

 build: context: . dockerfile: Dockerfile # путь до Dockerfile 

Therefore COPY package.json does not work - there is no file.

Use version api version 3 - links bad practice.