Skip to content

Commit fac99ad

Browse files
Merge pull request #113 from StefanScherer/update-registry-2.6.1
Update registry 2.6.1
2 parents bb484e3 + 8dc694f commit fac99ad

7 files changed

Lines changed: 96 additions & 50 deletions

File tree

registry/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

registry/Dockerfile

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,36 @@
1+
FROM golang:1.8-nanoserver
2+
3+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
4+
5+
ENV DOCKER_BUILDTAGS include_oss include_gcs
6+
ENV DISTRIBUTION_VERSION v2.6.1
7+
8+
ENV GIT_VERSION 2.11.0
9+
ENV GIT_DOWNLOAD_URL https://github.com/git-for-windows/git/releases/download/v${GIT_VERSION}.windows.1/MinGit-${GIT_VERSION}-64-bit.zip
10+
11+
RUN Invoke-WebRequest -UseBasicParsing $env:GIT_DOWNLOAD_URL -OutFile git.zip; \
12+
Expand-Archive git.zip -DestinationPath C:\git; \
13+
Remove-Item git.zip; \
14+
Write-Host 'Updating PATH ...'; \
15+
$env:PATH = 'C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin;' + $env:PATH; \
16+
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH
17+
18+
RUN mkdir src\github.com\docker ; \
19+
cd src\github.com\docker ; \
20+
git clone -q https://github.com/docker/distribution ; \
21+
cd distribution ; \
22+
git checkout -q $env:DISTRIBUTION_VERSION ; \
23+
try { go get github.com/tools/godep 2>&1 } catch { } ; \
24+
try { go get github.com/tools/godep } catch { } ; \
25+
Start-Process -FilePath godep.exe -ArgumentList go, build, ./cmd/registry -Wait
26+
127
FROM microsoft/nanoserver
228
3-
COPY ./registry.exe /registry.exe
29+
COPY --from=0 /gopath/src/github.com/docker/distribution/registry.exe /registry.exe
430
COPY config.yml /config/config.yml
531
6-
# VOLUME ["/registry"]
7-
# EXPOSE 5000
32+
VOLUME C:\\registry
33+
EXPOSE 5000
834
935
ENTRYPOINT ["\\registry.exe"]
1036
CMD ["serve", "/config/config.yml"]

registry/README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,43 @@
22

33
Run your own Docker Registry in a Windows Docker container.
44

5-
As with TP5 there is still a problem contacting containers from your Docker host locally (see [issue #253](https://github.com/Microsoft/Virtualization-Documentation/issues/253) for some details), I suggest to use two TP5 machines for now.
5+
As with Windows Server 2016 there is still a problem contacting containers from your Docker host locally (see [issue #253](https://github.com/Microsoft/Virtualization-Documentation/issues/253) for some details), I suggest to use two Windows Server 2016 machines for now.
66

77
## Create a folder on your host
88

9-
On the first TP5 we setup a local folder to persist your images.
9+
On the first Windows Server 2016 we setup a local folder to persist your images.
1010

1111
```
1212
mkdir C:\registry
1313
```
1414

1515
## Run registry in container
1616

17-
On the first TP5 machine run the registry like this:
17+
On the first Windows Server 2016 machine run the registry like this:
1818

1919
```
20-
docker run -d -p 5000:5000 --restart=always --name registry -v C:\registry:C:\registry stefanscherer/registry-windows:2.4.1
20+
docker run -d -p 5000:5000 --restart=always --name registry -v C:\registry:C:\registry stefanscherer/registry-windows:2.6.1
2121
```
2222

23-
## Edit your Docker Engine config filesystem
23+
## Edit your Docker Engine config file
2424

25-
On the second TP5 machine add your local registry from the first TP5 machine. In this example the IP address of the first TP5 machine is 192.168.254.133.
25+
On the second Windows Server 2016 machine add your local registry from the first Windows Server 2016 machine. In this example the IP address of the first Windows Server 2016 machine is 192.168.254.133.
2626

2727
```
28-
notepad C:\ProgramData\docker\runDockerDaemon.cmd
28+
notepad C:\ProgramData\docker\config\daemon.json
2929
```
3030

31-
Add your Registry to the start command:
31+
```json
32+
{
33+
"insecure-registries": [ "192.168.254.133:5000" ]
34+
}
35+
```
36+
37+
Or add your Registry to the start command:
3238

3339
```
34-
dockerd -G docker -H npipe:// -H 0.0.0.0:2375 --insecure-registry 192.168.254.133:5000
40+
dockerd --unregister-service
41+
dockerd --register-service -G docker -H npipe:// --insecure-registry 192.168.254.133:5000
3542
```
3643

3744
## Restart Docker Engine
@@ -43,15 +50,15 @@ restart-service docker
4350
## Tag a Docker image
4451

4552
```
46-
docker tag stefanscherer/registry-windows:2.4.1 192.168.254.133:5000/registry:2.4.1
53+
docker tag stefanscherer/registry-windows:2.6.1 192.168.254.133:5000/registry:2.6.1
4754
```
4855

4956
## Push a Docker image
5057

5158
```
52-
docker push 192.168.254.133:5000/registry:2.4.1
59+
docker push 192.168.254.133:5000/registry:2.6.1
5360
```
5461

5562
## Check C:\registry
5663

57-
On the first TP5 machine check the `C:\registry` folder and you will see some directories and files containing the images and meta information.
64+
On the first Windows Server 2016 machine check the `C:\registry` folder and you will see some directories and files containing the images and meta information.

registry/build.ps1

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
echo Building registry binary
2-
docker build -t registry-builder build
3-
docker create --name registry-builder registry-builder
4-
docker cp registry-builder:/gopath/src/github.com/docker/distribution/registry.exe ./registry.exe
1+
Write-Host Updating Docker engine to master
2+
Stop-Service docker
3+
$wc = New-Object net.webclient
4+
$wc.Downloadfile("https://master.dockerproject.org/windows/amd64/dockerd.exe", "$env:ProgramFiles\docker\dockerd.exe")
5+
$wc.Downloadfile("https://master.dockerproject.org/windows/amd64/docker.exe", "$env:ProgramFiles\docker\docker.exe")
6+
Start-Service docker
7+
docker version
58

6-
echo Building registry image
9+
Write-Host Building registry binary and image
710
docker build -t registry .
8-
docker tag registry:latest registry:2.6.0
11+
docker tag registry:latest registry:2.6.1

registry/build/Dockerfile

Lines changed: 0 additions & 25 deletions
This file was deleted.

registry/push.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
docker tag registry:2.6.0 stefanscherer/registry-windows:2.6.0
2-
docker tag registry:2.6.0 stefanscherer/registry-windows:latest
3-
docker push stefanscherer/registry-windows:2.6.0
1+
docker tag registry:2.6.1 stefanscherer/registry-windows:2.6.1
2+
docker tag registry:2.6.1 stefanscherer/registry-windows:latest
3+
docker push stefanscherer/registry-windows:2.6.1
44
docker push stefanscherer/registry-windows:latest

registry/test.ps1

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
$ErrorActionPreference = 'Stop'
2+
3+
function addRegistryToDaemonJson() {
4+
Write-Host "Adding registry"
5+
$daemonJson = "$env:ProgramData\docker\config\daemon.json"
6+
$config = @{}
7+
if (Test-Path $daemonJson) {
8+
$config = (Get-Content $daemonJson) -join "`n" | ConvertFrom-Json
9+
}
10+
$config = $config | Add-Member(@{ `
11+
'insecure-registries' = @("127.0.0.1:5000"); `
12+
}) -Force -PassThru
13+
$config | ConvertTo-Json | Set-Content $daemonJson -Encoding Ascii
14+
}
15+
16+
function addPortMapping() {
17+
netsh interface portproxy add v4tov4 listenport=5000 listenaddress=127.0.0.1 connectport=5000 connectaddress=$(docker inspect -f '{{ .NetworkSettings.Networks.nat.IPAddress }}' registry)
18+
}
19+
20+
function runRegistry() {
21+
mkdir C:\registry
22+
docker run -d -p 5000:5000 --restart=always --name registry -v C:\registry:C:\registry registry:2.6.1
23+
}
24+
25+
26+
addRegistryToDaemonJson
27+
restart-service docker
28+
runRegistry
29+
addPortMapping
30+
31+
Write-Host Pushing an image to local registry
32+
docker tag registry:2.6.1 127.0.0.1:5000/registry:2.6.1
33+
docker push 127.0.0.1:5000/registry:2.6.1
34+
35+
Write-Host Checking if local registry files are stored on host
36+
dir C:\registry\docker\registry\v2\repositories\registry\

0 commit comments

Comments
 (0)