0

I don't see why docker doesn't build my Dockerfile. The Dockerfile is present but is complaining it can't locate it. What am I missing here? I'm at my wits end right now.

Dockerfile is present, unless my eyes are playing tricks on me. I think it's spelled correctly too.

$ ls
Dockerfile  pct  runme.sh
$

Error message I'm getting when running docker build

$ cat /tmp/context.tar | docker build -f Dockerfile -t iii - 
Sending build context to Docker daemon  665.6kB
Error response from daemon: Cannot locate specified Dockerfile: Dockerfile
$
Classified
  • 5,759
  • 18
  • 68
  • 99
  • 1
    You're trying to `cat` the contents of what appears to be a `tar` file. Did you mean something like `tar -xf -` instead? – stdunbar Jan 31 '23 at 22:27
  • 1
    `-` means that the Dockerfile is in stdin. Try `cat Dockerfile | docker build - -t iii /tmp/context.tar` – Hans Kilian Jan 31 '23 at 22:41
  • @stdunbar, thx, I was just copying the command I found on another script internally. I don't know what voodoo the person was doing but it worked for them. After I played with the docker build command, I think I figured out how to get it working. I can post what I found as an answer or we can delete my question here if needed. – Classified Jan 31 '23 at 23:48
  • @HansKilian, thx. After playing with the docker build command and reading your comment, I figured out how to get it working. – Classified Jan 31 '23 at 23:49

2 Answers2

0

So after playing with the docker build command, I got it working. I don't know how/why the person catted the tar file and then piped it to docker build but it worked for them but not for me.

The command that worked for me was:

$ docker build -f Dockerfile my_dir/ -t image_name
Classified
  • 5,759
  • 18
  • 68
  • 99
0

don't know how/why the person catted the tar file and then piped it to docker build

At the end of the day, Docker images are just a collection of tarballs.

Are you sure they were actually using a Dockerfile? That's not a requirement.

cat context.tar | docker build - 

or , to prevent UUOC

docker build < context.tar

docker load would be better for this.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245