Skip to content

Instantly share code, notes, and snippets.

@dlorenc
Created December 29, 2020 13:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlorenc/247222f619d78d070d574c7f1fd7d688 to your computer and use it in GitHub Desktop.
Save dlorenc/247222f619d78d070d574c7f1fd7d688 to your computer and use it in GitHub Desktop.
# First try, we get edb8f4a65586 as our hash
$ cat << EOF | docker build --no-cache -
> FROM alpine
> RUN touch foo
> EOF
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM alpine
---> a24bb4013296
Step 2/2 : RUN touch foo
---> Running in 9687f21f4edb
Removing intermediate container 9687f21f4edb
---> edb8f4a65586
Successfully built edb8f4a65586
# Do it again! We get a different hash: 9617b400b61e
$ cat << EOF | docker build --no-cache -
> FROM alpine
> RUN touch foo
> EOF
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM alpine
---> a24bb4013296
Step 2/2 : RUN touch foo
---> Running in 36d808046160
Removing intermediate container 36d808046160
---> 9617b400b61e
Successfully built 9617b400b61e
# Now drop the --no-cache flag and we get the same hash!
$ cat << EOF | docker build -
> FROM alpine
> RUN touch foo
> EOF
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM alpine
---> a24bb4013296
Step 2/2 : RUN touch foo
---> Using cache
---> 9617b400b61e
Successfully built 9617b400b61e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment