Running a Local Docker Registry with PowerShell

Running a Local Docker Registry with PowerShell

Setting up a local Docker registry is a great way to manage and share container images in your development environment without relying on external services like Docker Hub. This guide walks you through setting up a private Docker registry on your machine using PowerShell on Windows.


Prerequisites

  • Docker Desktop installed
  • Windows PowerShell
  • Optional: curl or Invoke-RestMethod for testing

Step 1: Start the Docker Registry Container

Docker provides an official image for the registry. You can launch it using PowerShell:

1docker run -d `
2  -p 5000:5000 `
3  --restart=always `
4  --name registry `
5  registry:2

This will expose your registry at http://localhost:5000.

Step 2: Test the Registry

Let’s push a simple image to the local registry:

1# Pull an example image
2docker pull hello-world
3
4# Tag it for the local registry
5docker tag hello-world localhost:5000/hello-world
6
7# Push it to the local registry
8docker push localhost:5000/hello-world

Step 3: Check Available Images

To verify that the image was stored, run:

1Invoke-RestMethod -Uri http://localhost:5000/v2/_catalog
1{
2  "repositories": [
3    "hello-world"
4  ]
5}

Conclusion

With just a few commands, you can spin up your own private Docker registry for local development. It’s a great tool for testing, internal CI/CD workflows, or teams working in isolated environments.


Comments

Twitter Facebook LinkedIn WhatsApp