Docker, start to ship · Chapter 25 of 26
Your own registry
By the end of this chapter you can run a registry, push an image to it, pull it back on a machine that has none, and run an image pinned by its digest. Build it in your browser: a real editor and terminal, AI that explains, and tests that tell you when it works.
- Part: Production habits
- 5 tasks
- Docker
- In the all labs plan
The first 2 chapters of Docker, start to ship are free. This one comes with the all labs plan.
Why you need this
The menu image, chai-25-menu:1.0, exists only on this machine. Ravi needs the servers to fetch it themselves. Bunty's plan is chapter 6's: docker save a tar file and copy it to each server by hand. That is a slow copy per server, and a month later nobody can say which tar file a server is running. Dev wants every server to run exactly the image that was tested.
Servers get images from a registry, the way you would from Docker Hub. The lab has no internet, so Tapri runs its own, and a registry is just another container.
What you build: 5 tasks
Each task has tests. You write the code in the lab's editor and press Check.
- Task 1
Run Tapri's registry as chai-25-registry on 8025
Run Tapri's own registry in a container.
1. Run a container named chai-25-registry from the lab's registry:2 image, in the background.
2. Publish the registry's port 5000 on the lab's port 8025.
3. Run curl localhost:8025/v2/_catalog. A list of repositories, even an empty one, means it works.
To pass: chai-25-registry is running from the registry image, and localhost:8025/v2/_catalog answers.
- Task 2
Push chai-25-menu:1.0 to the registry
Push the menu image to Tapri's registry.
1. Give the image chai-25-menu:1.0 a second name: localhost:8025/chai-25-menu:1.0.
2. Push that name. This registry uses plain HTTP, so tell the push not to ask for TLS.
3. Ask the registry for its catalog, then for the tags of chai-25-menu.
To pass: the registry's catalog has chai-25-menu, and its tags list has 1.0.
- Task 3
Delete every local copy and pull it back
Delete every copy of the menu image on this machine, then pull it back from the registry.
1. Delete both names with docker rmi: chai-25-menu:1.0 and localhost:8025/chai-25-menu:1.0.
2. Run docker images to be sure the menu image is gone.
3. Pull localhost:8025/chai-25-menu:1.0 back with docker pull, again with no TLS.
4. Run docker images again.
To pass: docker rmi on the menu image worked, and after it, docker pull of localhost:8025/chai-25-menu:1.0 worked. Type both in the terminal, in the chapter folder. At the end, the lab has localhost:8025/chai-25-menu:1.0 and no chai-25-menu:1.0.
- Task 4
Run chai-25-menu on 8075 pinned by its digest
Run the menu from its exact digest, not from a tag.
1. Find the registry's digest of the image you pulled back in task 3. It is sha256: and 64 characters.
2. Save the whole digest in digest.txt, in the chapter folder.
3. Run a container named chai-25-menu, in the background, from localhost:8025/chai-25-menu@ followed by that digest.
4. Publish its port 80 on the lab's port 8075. Then run curl localhost:8075.
To pass: digest.txt has the registry's digest of chai-25-menu:1.0. chai-25-menu is running, started from exactly localhost:8025/chai-25-menu@ and that digest, with no tag. localhost:8075 shows Tapri menu 1.0.
- Task 5 · interview question
Interview: how a tag differs from a digest
Interview question: how is a tag different from a digest?
1. Think: what can happen to a tag that cannot happen to a digest?
2. Think: why can it not happen to a digest?
3. Write one or two sentences in your own words in answer.txt, in the chapter folder. Say something about tags and something about digests.
To pass: answer.txt says what can happen to a tag, and why a digest is different.
What you will learn
- The registry image: a registry in a container, with a small HTTP API.
- docker tag, docker push and docker pull: an image's name says which registry it lives in.
- Digests: the hash that names one exact image, and how to run an image by it.
More in Production habits
Build "Your own registry" yourself
Tapri’s menu site works on one laptop and nowhere else. You ship the machine. A real editor and terminal in your browser, AI that explains, and a Check that says when it works.
The first 2 chapters of Docker, start to ship are free. This one comes with the all labs plan.