According to the Docker v1.18 API documentation, the /build
method accepts a TAR stream (with a Dockerfile) and attempts to build the image.
However, unless I'm missing something, there seems to be no way to obtain the image ID after the build process completes.
For example, I'm using the go-dockerclient library to connect to the Docker API and build the image using the following snippet:
//...
opts := docker.BuildImageOptions{
Name: "test-image",
InputStream: input,
OutputStream: output,
}
if err := client.BuildImage(opts); err != nil {
fmt.Println(err)
}
//...
The BuildImage()
method executes and I can confirm (through Docker's CLI client) that the image is indeed created. However, the only value returned from BuildImage()
is an error. There doesn't seem to be a way to obtain the ID of the image.
Am I missing something?