Container Image Build and Publish Workflow
A practical guide to building, testing, tagging, and publishing container images while keeping the build context controlled.
From to Registry
What is being built?
A packages a filesystem and configuration used to create containers. It is built from instructions—commonly written in a Dockerfile—and a , the files made available to the builder. Keeping that context small limits what is sent to the builder and helps make the build workflow controlled.
Build, test, and publish
Assuming the project has a Dockerfile, this Docker workflow builds an image from the current directory, runs it for testing, gives it a registry-ready name, authenticates to the registry, and pushes it:
docker build -t myapp:1.4.0 .
docker run --rm myapp:1.4.0
docker tag myapp:1.4.0 registry.example.com/team/myapp:1.4.0
docker login registry.example.com
docker push registry.example.com/team/myapp:1.4.0
The final . in the build command means the current directory is the . The -t option names the built image myapp:1.4.0. Next, docker run --rm starts a container from that image for testing and removes the container when it exits; it does not remove the image. After testing, docker tag assigns the same image a name that includes the registry and team path. This makes the intended destination explicit. docker login authenticates with that registry, and docker push uploads the tagged image there.
Image layers can be reused across builds and shared through registries. Reuse can make builds more efficient, while registry sharing makes images available for deployment. The sequence matters: build and test locally first, then name, authenticate, and publish the image.