Answer the question
In order to leave comments, you need to log in
How to raise node.js + mysql via docker-compose?
What is the problem ?
When running docker-compose up --build gives
this error, I understand that the problem is in the COPY command, but I do not understand what exactly is wrong.
Building app
Step 1/6 : FROM node:11
---> 5b97b72da029
Step 2/6 : WORKDIR /src
---> Using cache
---> a33787f5ff60
Step 3/6 : COPY package*.json /src
ERROR: Service 'app' failed to build: COPY failed: no source files were specified
FROM node:11
WORKDIR /src
COPY package*.json /src
RUN npm install mysql
COPY . .
CMD ["node", "index.js"]
version: '3.7'
services:
db:
image: mysql:5.7
ports:
- 3306:3306
expose:
- 3306
environment:
MYSQL_ROOT_PASSWORD: '${MYSQL_ROOT_PASSWORD}'
MYSQL_DATABASE: '${MYSQL_DATABASE}'
MYSQL_USER: '${MYSQL_USER}'
MYSQL_PASSWORD: '${MYSQL_PASSWORD}'
app:
build: ./docker/node/
image: nodejs
container_name: nodejs
restart: unless-stopped
environment:
MYSQL_HOST: '${MYSQL_HOST}'
MYSQL_DATABASE: '${MYSQL_DATABASE}'
MYSQL_USER: '${MYSQL_USER}'
MYSQL_PASSWORD: '${MYSQL_PASSWORD}'
MYSQL_PORT: 3306
volumes:
- ./src:/src/
ports:
- 3000:3000
depends_on:
- db
Answer the question
In order to leave comments, you need to log in
Build comes from the current directory. The file with the package in the Dockerfile is relative to the src directory
This is the error
Most likely - the easiest way to solve it is to add it to context: ./src
the docker compose
And I highly recommend that you familiarize yourself with the concept of docker context
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question