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

前端 未结 7 1805
野趣味
野趣味 2021-01-31 12:57

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 fo

7条回答
  •  时光说笑
    2021-01-31 13:46

    It's simple, whenever Docker build is run, docker wants to know, what's the image name, so we need to pass -t : . Now make sure you are in the same directory where you have your Dockerfile and run

    docker build -t : . Example docker build -t my_apache:latest . assuming you are in the same directory as your Dockerfile otherwise pass -f flag and the Dockerfile.

    docker build -t my_apache:latest -f ~/Users/documents/myapache/Dockerfile

提交回复
热议问题