Search code examples
dockerdockerfile

Docker build gives "unable to prepare context: context must be a directory: /Users/tempUser/git/docker/Dockerfile"


I have a Dockerfile that is supposed to build an Ubuntu image. But whenever I run

docker build -t ubuntu-test:latest ./Dockerfile

it shows the following error on the console

unable to prepare context: context must be a directory: /Users/tempUser/git/docker/Dockerfile

I'm on Mac OsX. I tried to sudo as well. Nothing works.


Solution

  • You need to point to the directory instead. You must not specify the dockerfile.

    docker build -t ubuntu-test:latest . does work.

    docker build -t ubuntu-test:latest ./Dockerfile does not work.