0
0
Dockerdevops~10 mins

Setting up private registry in Docker - Visual Walkthrough

Choose your learning style9 modes available
Process Flow - Setting up private registry
Start Docker Registry Container
Docker Registry Runs Locally
Tag Local Image with Registry Address
Push Image to Private Registry
Pull Image from Private Registry
Use Image in Docker Environment
This flow shows starting a private Docker registry, tagging images, pushing them to the registry, and pulling them back for use.
Execution Sample
Docker
docker run -d -p 5000:5000 --name registry registry:2

docker tag myapp localhost:5000/myapp

docker push localhost:5000/myapp

docker pull localhost:5000/myapp
Commands to start a private registry, tag an image, push it to the registry, and pull it back.
Process Table
StepCommandActionResult
1docker run -d -p 5000:5000 --name registry registry:2Start registry containerRegistry container running on port 5000
2docker tag myapp localhost:5000/myappTag local imageImage 'myapp' tagged as 'localhost:5000/myapp'
3docker push localhost:5000/myappPush image to registryImage pushed to private registry at localhost:5000
4docker pull localhost:5000/myappPull image from registryImage pulled from private registry
5-EndPrivate registry setup and image transfer complete
💡 All steps completed successfully; private registry is running and images are stored locally.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4Final
registry_containernot runningrunningrunningrunningrunningrunning
image_tagmyappmyapplocalhost:5000/myapplocalhost:5000/myapplocalhost:5000/myapplocalhost:5000/myapp
image_locationlocal onlylocal onlylocal and tagged for registrypushed to registryavailable locallyavailable locally
Key Moments - 3 Insights
Why do we tag the image with 'localhost:5000/myapp' before pushing?
Tagging with 'localhost:5000/myapp' tells Docker to push the image to the private registry running on localhost port 5000, as shown in step 2 of the execution table.
What happens if the registry container is not running before pushing?
If the registry container is not running (step 1), the push command in step 3 will fail because there is no registry to receive the image.
Does pulling the image from the private registry overwrite the local image?
Yes, pulling the image from the private registry (step 4) updates or adds the image locally tagged as 'localhost:5000/myapp', as tracked in the variable_tracker.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the state of the registry container after step 1?
ANot running
BRunning on port 5000
CStopped
DCrashed
💡 Hint
Check the 'Result' column in row for step 1 in the execution_table.
At which step is the image tagged for the private registry?
AStep 1
BStep 3
CStep 2
DStep 4
💡 Hint
Look at the 'Action' column in the execution_table for tagging.
If the registry container was not running, what would happen at step 3?
APush would fail
BImage would push successfully
CImage would be deleted
DImage would be pulled instead
💡 Hint
Refer to key_moments about registry container state and push command.
Concept Snapshot
Setting up a private Docker registry:
1. Run registry container: docker run -d -p 5000:5000 --name registry registry:2
2. Tag image: docker tag myapp localhost:5000/myapp
3. Push image: docker push localhost:5000/myapp
4. Pull image: docker pull localhost:5000/myapp
This allows storing and sharing images locally without Docker Hub.
Full Transcript
To set up a private Docker registry, first run the registry container on your machine using 'docker run -d -p 5000:5000 --name registry registry:2'. This starts a registry listening on port 5000. Next, tag your local image with the registry address using 'docker tag myapp localhost:5000/myapp'. This tells Docker where to push the image. Then push the image to your private registry with 'docker push localhost:5000/myapp'. Finally, you can pull the image back from the registry using 'docker pull localhost:5000/myapp'. This process keeps your images stored locally and accessible without using public Docker Hub.