|
| 1 | +# registry |
| 2 | + |
| 3 | +[](https://hub.docker.com/r/stefanscherer/registry-windows/) |
| 4 | + |
| 5 | +Run your own Docker Registry in a Windows Docker container. This is a multi-os image for Windows Server LTSC2019 and LTSC2022. |
| 6 | + |
| 7 | +You can run this container on your Windows Host, at the time of this guide, these steps were tested on a Windows 11 host. |
| 8 | + |
| 9 | +## Build the container |
| 10 | + |
| 11 | +In the repository root, navigate to the registry folder and run the following command: |
| 12 | + |
| 13 | +```console |
| 14 | +docker build -f .\Dockerfile -t my/registry-windows:ltsc2019 . |
| 15 | +``` |
| 16 | + |
| 17 | +> You can also edit the [Dockerfile](Dockerfile) to use `mcr.microsoft.com/windows/nanoserver:ltsc2019` instead if you'd prefer to build for nanoserver ltsc2019. |
| 18 | +
|
| 19 | +## Create a folder on your host |
| 20 | + |
| 21 | +On your Windows host setup a local folder to persist your images. |
| 22 | + |
| 23 | +```console |
| 24 | +mkdir C:\registry |
| 25 | +``` |
| 26 | + |
| 27 | +## Run insecure registry without TLS |
| 28 | + |
| 29 | +If you don't have SSL certificates for your domain and don't wont to use self-signed certificates you can just setup you registry as follows |
| 30 | + |
| 31 | +### Edit your Docker Engine config file |
| 32 | + |
| 33 | +On your Windows host machine add an entry for `localhost:5000`. We need to add this as we didn't use certificates to secure the registry. |
| 34 | + |
| 35 | +```console |
| 36 | +notepad C:\ProgramData\docker\config\daemon.json |
| 37 | +``` |
| 38 | + |
| 39 | +```json |
| 40 | +{ |
| 41 | + "insecure-registries": ["localhost:5000"] |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +Or add your Registry to the start command: |
| 46 | + |
| 47 | +```console |
| 48 | +dockerd --unregister-service |
| 49 | +dockerd --register-service -G docker -H npipe:// --insecure-registry localhost:5000 |
| 50 | +``` |
| 51 | + |
| 52 | +### Restart Docker Engine |
| 53 | + |
| 54 | +```console |
| 55 | +restart-service docker |
| 56 | +``` |
| 57 | + |
| 58 | +### Run registry in container |
| 59 | + |
| 60 | +On the first Windows Server machine run the registry like this: |
| 61 | + |
| 62 | +```console |
| 63 | +docker run -d -p 5000:5000 --restart=always --name registry -v C:\registry:C:\registry my/registry-windows:ltsc2019 |
| 64 | +``` |
| 65 | + |
| 66 | +## Tag a Docker image |
| 67 | + |
| 68 | +You now have a registry in place, secure or insecure, and you can run the following to tag a Docker image |
| 69 | + |
| 70 | +```console |
| 71 | +docker tag my/registry-windows:ltsc2019 localhost:5000/registry:2.6.2 |
| 72 | +``` |
| 73 | + |
| 74 | +## Push a Docker image |
| 75 | + |
| 76 | +You can push your tagged image to your registry |
| 77 | + |
| 78 | +```console |
| 79 | +docker push localhost:5000/registry:2.6.2 |
| 80 | +``` |
| 81 | + |
| 82 | +## Check C:\registry |
| 83 | + |
| 84 | +On the Windows host machine check the `C:\registry` folder and you will see some directories and files containing the images and meta information. |
0 commit comments