Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.7K
Views
"COPY failed: no source files were specified" when Dockerfile is not in root directory on Docker Hub

When I run my application through docker-compose up, it builds and runs without any issues. When I try to host it on Docker Hub, it fails to build with the error COPY failed: no source files were specified. I believe it is because the Dockerfile is not in the root directory.

My folder structure is like this:

root
-- docker-compose.yml
-- app
   -- Dockerfile
   -- package.json
   -- package-lock.json
   -- src
      -- .....

My Dockerfile is below, and when I run docker-compose up (which points to the Dockerfile within /app) it runs fine:

FROM node:8.10.0-alpine
WORKDIR /usr/src/app
COPY package*.json /usr/src/app/
RUN npm install --production
COPY . /usr/src/app
EXPOSE 4000
CMD ["npm", "run", "app"]

I am wanting to host my project on Docker Hub, but I'm getting the following error:

Step 1/7 : FROM node:8.10.0-alpine
---> adc4b0f5bc53
Step 2/7 : WORKDIR /usr/src/app
Removing intermediate container 743246352cea
---> 3dcb720d4618
Step 3/7 : COPY package*.json /usr/src/app/
COPY failed: no source files were specified

The build rules I've set to point to the correct Dockerfile location is below:

Docker Hub build rules showing Dockerfile location as app/Dockerfile

Is my Dockerfile wrong, or am I not configuring Docker Hub correctly when I try to hook it up to my GitHub repo?

For context, the GitHub repo is here.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

In the build configuration, you need to configure the "build context" directory rather than changing the Dockerfile location. Otherwise, the build will run in the parent of your github repo where the package*.json files do not exist. Note the column after "Dockerfile location" when configuring automated builds in the example below:

enter image description here

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!