Skip to content

Commit fd3cdc8

Browse files
authored
wip check registry with docker distribution + nano (#464)
1 parent f00fd42 commit fd3cdc8

4 files changed

Lines changed: 96 additions & 9 deletions

File tree

registry/Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@ FROM golang as build
33
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
44

55
ENV DOCKER_BUILDTAGS include_oss include_gcs
6-
ENV DISTRIBUTION_VERSION v2.6.2
6+
ENV DISTRIBUTION_VERSION main
77

8-
RUN mkdir src\github.com\docker ; \
9-
cd src\github.com\docker ; \
10-
git clone -q https://github.com/docker/distribution ; \
8+
# Update to point to newer docker distribution repo
9+
RUN mkdir src\github.com\distribution ; \
10+
cd src\github.com\distribution ; \
11+
git clone -q https://github.com/distribution/distribution ; \
1112
cd distribution ; \
1213
git checkout -q $env:DISTRIBUTION_VERSION ; \
1314
go build -o registry.exe cmd/registry/main.go
1415

16+
# You can also use mcr.microsoft.com/windows/nanoserver:ltsc2022
17+
FROM mcr.microsoft.com/windows/nanoserver:ltsc2019
1518

16-
FROM mcr.microsoft.com/windows/nanoserver:sac2016
17-
18-
COPY --from=build /gopath/src/github.com/docker/distribution/registry.exe /registry.exe
19+
COPY --from=build /go/src/github.com/distribution/distribution/registry.exe /registry.exe
1920
COPY config.yml /config/config.yml
2021

2122
EXPOSE 5000
2223

2324
ENTRYPOINT ["\\registry.exe"]
24-
CMD ["serve", "/config/config.yml"]
25+
CMD ["serve", "/config/config.yml"]

registry/build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
..\update-docker.ps1
1+
# ..\update-docker.ps1
22

33
Write-Host Building registry binary and image
44
$version=$(select-string -Path Dockerfile -Pattern "ENV DISTRIBUTION_VERSION").ToString().split()[-1].SubString(1)

registry/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ health:
1616
enabled: true
1717
interval: 10s
1818
threshold: 3
19+
validation:
20+
disabled: true

registry/local-host-testing.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# registry
2+
3+
[![This image on DockerHub](https://img.shields.io/docker/pulls/stefanscherer/registry-windows.svg)](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

Comments
 (0)