In Docker Hub images there are lists of commands that being run for each image layer. Here is a golang example.
Some applications also provide their Dockerfile in GitHub. Here is a golang example.
According to the Docker Hub image layer, ADD file:4b03b5f551e3fbdf47ec609712007327828f7530cc3455c43bbcdcaf449a75a9 in /
is the first command. The image layer doesn't have any "FROM" command included, and it doesn't seem to be suffice the ADD definition too.
So here are the questions:
ADD file:<HASH> in /
means? What is this format?FROM
image, but it seems there are no API for that.ADD file:<HASH> in /
syntax? Is there any way I could build an image using such syntax, OR do a conversion between two format?The ADD command is used to copy files/directories into a Docker image. It can copy data in three ways: Copy files from the local storage to a destination in the Docker image. Copy a tarball from the local storage and extract it automatically inside a destination in the Docker image.
COPY is a docker file command that copies files from a local source location to a destination in the Docker container. ADD command is used to copy files/directories into a Docker image. It only has only one assigned function. It can also copy files from a URL.
That Docker Hub history view doesn't show the actual Dockerfile; instead, it shows content essentially extracted from the docker history
of the image. That doesn't preserve the specific details you're looking for: it doesn't remember the names of base images, or the build-context file names of things that get ADD
ed or COPY
ed in.
Chasing through GitHub and Docker Hub links, the golang:*-buster
Dockerfile is built FROM buildpack-deps:...-scm
; buildpack-deps:buster-scm
is FROM buildpack-deps:buster-curl
; that is FROM debian:buster
; and that has a very simple Dockerfile (quoted here in its entirety):
FROM scratch
ADD rootfs.tar.xz /
CMD ["bash"]
FROM scratch
starts from a completely totally empty image; that is the base of the Docker image tree (and what tells docker history
and similar tools to stop). The ADD
line unpacks a tar file of a Debian system image.
If you look at docker history
or the Docker Hub history view you cite, you should be able to see these same steps happening. The ADD file:4b0... in /
corresponds to the ADD rootfs.tar.gz /
, and the second line is the CMD ["bash"]
. It is not split up by Dockerfile or image, and the original filenames from ADD
aren't saved. (You couldn't reproduce the image anyways without the contents of the rootfs.tar.gz
, so it's merely slightly helpful to know its filename but not essential.)
The ADD file:hash in /path
syntax is not standard Dockerfile syntax (the word in
in particular is not part of it). I'm not sure there's a reliable way to translate from the host file or URL to the hash, but building the image and looking at its docker history
would tell you (assuming you've got a perfect match for the file metadata). There's no way to get back to the original filename or syntax, and definitely no way to get back to the file contents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With