0

As I understand from Docker API reference if I have a build context for my new image, I have to create a tarball and send an URI via remote param. It's really inconvenient for me because I already have everything on the same host as the docker daemon. Is it possible somehow to use a PATH the same way you do with docker CLI?

docker built -t myimage:tag PATH
chingis
  • 1,514
  • 2
  • 19
  • 38

1 Answers1

0

Normally, you would post the tar'd files as e.g. explained here: Build image using dockerfile. In this case, you don't need a remote param at all. It's easy with curl.

If you perhaps aren't using curl and that is still inconvenient, you could run a small Docker container that serves your build files over http.

file:// doesn't work in current versions of Docker. Maybe it'll be added at some point, but probably not. git:// is supported.


(The following is more an aside, and I hope that this doesn't confuse you. I'd recommend not using this:)

Reading the source I stumbled upon some uncareful? coding that may allow you to use local git repositories if the directory name starts with git@ and is located in the CWD of the dockerd daemon (which you can find out with ls -l /proc/`pidof dockerd`/cwd. It's probably /.). Taking this one step further, if you create a symbolic link called git@ and point it to /, you can then do git@/home/.../... to access any other directory you need. However, this directory needs to be a git repository with everything committed.

So let's say I have a directory called git@ in dockerd's working directory and a git-committed Dockerfile with e.g. the contents:

FROM debian
CMD sleep inf

Then I can build that using:

curl http://localhost:2375/build?remote=git@
sneep
  • 1,828
  • 14
  • 19