Project: Ship It
Shipping the app means building the image, tagging it with a version, and pushing it to a registry. The checklist at the end names what to learn next.
Build with a version
This command builds the app image as version 1.0.
docker build -t g6-flaskapp:1.0 .Tag it for the registry
The tag carries the registry address and the version.
docker tag g6-flaskapp:1.0 localhost:8115/g6-flaskapp:1.0Push it and pull it back
The push stores it, and the pull proves it is there.
docker push localhost:8115/g6-flaskapp:1.0
docker pull localhost:8115/g6-flaskapp:1.0Example
docker run -d --name g6-reg -p 8115:5000 registry:2 >/dev/null
sleep 2
docker build -t g6-flaskapp:1.0 . >/dev/null
docker tag g6-flaskapp:1.0 localhost:8115/g6-flaskapp:1.0
docker push localhost:8115/g6-flaskapp:1.0
docker rmi localhost:8115/g6-flaskapp:1.0
docker pull localhost:8115/g6-flaskapp:1.0Key points
- Build the image with a version tag, like flaskapp:1.0.
- Tag it for the registry, like your-name/flaskapp:1.0.
- Push it, and pull it back on another machine to prove it is there.
- A shipped image runs the same on any machine with Docker.
- Next steps: Swarm for one-team orchestration, or Kubernetes for scale.
- Next steps: image scanning, and secrets from a store instead of files.
In this example, the app image is built, tagged for a local registry, pushed, removed, and pulled back. The pull proves the image shipped and can be fetched again. The same three commands ship it to Docker Hub with your name.
Note
A version tag is the promise. Latest moves, and 1.0 stays fixed.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
What proves a pushed image is really on the registry?