COPY failed: no source files were specified while docker-compose up

10,537

please check if your .gitignore file has ignored your source file.

Share:
10,537

Related videos on Youtube

Ashish Goyal
Author by

Ashish Goyal

Hi, I am a Second year undergraduate student at Jaypee Institute of Information Technology majoring in Computer Science And Engineering. I have been tinkering with code since many years and been a Full Stack Web Developer And Programmer since over 1 year. I love to code and develop personal projects & contribute on Open Source Projects.

Updated on June 04, 2022

Comments

  • Ashish Goyal
    Ashish Goyal almost 2 years

    Dockerfile for express API is like it:

    FROM node:10.15.3
    
    MAINTAINER AshishkrGoyal <[email protected]>
    
    #RUN mkdir -p /usr/src/app
    
    #define working dir
    WORKDIR /usr/src/app
    
    #available package.json, package-lock.json as well
    COPY package*.json ./
    
    #install all dependencies listed in package.json
    RUN npm install
    
    #copy all the source code to working dir
    COPY . .
    
    #mapping of port to docker daemon
    EXPOSE 3000
    
    #command in the form of array
    CMD ["npm", "run", "dev"]
    
    
    

    docker-compose.yml is like as shown below:

    #specify the docker-compose version
    version: '3.0'
    
    services:
    #specify all the services 
      angular: #it is frontend service container name
        build: public #dockerfile directory
        ports:
          - "4200:4200"
    
      express: #it is backend service container name
        build: server #dockerfile directory
        ports:
          - "3000:3000"
        links:
          - database
    
      database: #it is elastc search service container name
        image: docker.elastic.co/elasticsearch/elasticsearch:7.0.0
        ports:
            - "9200:9200"
    

    While running command docker-compose up i am getting following error: ERROR: Service 'express' failed to build: COPY failed: no source files were specified

    Please help me in solving this error.

    Thanks in advance!!

    • Ashish Goyal
      Ashish Goyal about 5 years
      It will copy all the code to the working directory as in my case it is /usr/src/app
    • BMitch
      BMitch about 5 years
      Is there a file matching package*.json within the server directory? Do you have a .dockerignore file, and if so, what are the contents? Can you show the entire build output up to the failure so we can see which step is failing since you have two COPY commands?
    • BMitch
      BMitch about 5 years
      @SherloxFR the copy source is the build context, the destination is the image, so each . is for a different location.
  • Ashish Goyal
    Ashish Goyal about 5 years
    Yes, i am running docker-compose up from the root of the project
  • David J Eddy
    David J Eddy about 5 years
    Perfect. Checkout the 'build context' configuration of docker-compose. docs.docker.com/compose/compose-file For Express provide the sub-dir name that is the 'root' of the Express project inside the over-all docker project.