Docker build from Dockerfile shows "ADD failed - No such file or directory"

Ok, for me it worked to use docker build . -f Dockerfile instead of docker build - < Dockerfile (which was the suggestion from the offical docker documentation by the way: https://docs.docker.com/engine/reference/commandline/build/#tarball-contexts). The solution was taken from github: https://github.com/moby/moby/issues/34986#issuecomment-343680872


The most common causes of this issue are:

  1. Incorrect path

  2. Having docker-builder in your .dockerignore


I found the same error message when I used docker-compose.yml with follows directory structure. I fixed it by updating the dockerfile path in the docker-compose.yml as follows.

.docker      
├── basic.conf
├── Dockerfile

My docker-compose.yml look like this when I found the error

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

I have solved the problem by update the docker-compose.yml as follows.

services:
  web:
    build:
      context: ./
      dockerfile: .docker/nginx/Dockerfile

Tags:

Docker

Nginx