Build, Tag, and Push a Docker Image with One Command
July 25, 2023 —
Gregg Szumowski
You can build, tag, and push a docker image to a remote all in one command with the –quiet parameter on docker build, which only outputs the SHA256 hash (annoyingly prefixed with SHA256:, but nothing a little cutting can’t fix).
$ docker tag $(docker build . -q | cut -c 8-999) myregid/imagename:1.0.1 && docker push myregid/imagename