0

when run this command

sudo docker build -t jhipster /home/abed/project/microServies/StudentApp/src/main/docker/dockerfile1

sudo docker build -t jhipster /home/abed/project/microServies/StudentApp/src/main/docker/dockerfile2

see this error:

unable to prepare context: context must be a directory: /home/abed/project/microServies/StudentApp/src/main/docker/dokcerfile1

unable to prepare context: context must be a directory: /home/abed/project/microServies/StudentApp/src/main/docker/dokcerfile2

i don't know this message what is do you meaning

and i have many docker file i must build and run but i cant run any file

Abdalrhman Alkraien
  • 645
  • 1
  • 7
  • 22
  • just run this: `sudo docker build -t jhipster /home/abed/project/microServies/StudentApp/src/main/docker/`, you need to provide the path of the directory to build a docker image and not the dockerfile path – Krishna Chaurasia Feb 17 '21 at 10:18
  • I see some more problems, why do you have multiple dockerfiles in the same directory. also the dockerfile name has to be `Dockerfile`, it can't have suffixes like `dockerfile1`, etc. – Krishna Chaurasia Feb 17 '21 at 10:20
  • i have app.yml ,jhipster-rigster.yml, kafka.yml and ..etc – Abdalrhman Alkraien Feb 17 '21 at 10:31

1 Answers1

1

Per the docker build docs, if you're specifying a Dockerfile that's either not exactly named Dockerfile or is not in your current directory, you should use the -f flag.

The error is telling you you provided an invalid build context. The build context should be a directory that contains anything you need to COPY or ADD into the image. Any COPY commands you have would be relative to the build context path.

Here's how you could use the -f flag and build context:

sudo docker build -t TAGNAME -f /path/to/dockerfile /path/to/build/context

For you, it really depends on the contents of your Dockerfile but your full command might be something like this:

sudo docker build -t jhipster -f /home/abed/project/microServies/StudentApp/src/main/docker/dockerfile1 /home/abed/project/microServies/StudentApp
cam
  • 4,409
  • 2
  • 24
  • 34