windows - gitlab-runner inde i docker image

Indlæg af Hanne Mølgaard Plasc

Problem



Jeg opsætter et Windows Docker-billede og startede det på min Windows 10-maskine.
I den løbende docker image registrerede gitlab løberen på min gitlab server.
Problemet er, at gitlab-serveren ser ip-adressen til værten Windows-maskine og som følge heraf er det online.


Er der alligevel at køre en byggepude i et interaktivt dockerbillede?


Her er min dockerfil


# escape=`

FROM microsoft/windowsservercore

RUN @"\%SystemRoot\%System32WindowsPowerShellv1.0powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=\%PATH\%;\%ALLUSERSPROFILE\%chocolateyin"

# wait for vs\_installer.exe, vs\_installerservice.exe
# or vs\_installershell.exe because choco doesn't
RUN powershell -NoProfile -InputFormat None -Command `
    choco install git 7zip -y; `
    choco install visualcpp-build-tools `
            -y; `
    Write-Host 'Waiting for Visual C++ Build Tools to finish'; `
    Wait-Process -Name vs\_installer

#WORKDIR C:uild
#CMD powershell -ExecutionPolicy Bypass -Command .
elease.ps1

COPY entrypoint.bat entrypoint.bat

# Install Chocolatey
#RUN powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET #"PATH=\%PATH\%;\%ALLUSERSPROFILE\%chocolateyin"    

# Register the GitLab Runner
COPY gitlab-runner-windows-amd64.exe /gitlab/gitlab-runner.exe
RUN /gitlab/gitlab-runner.exe install

SHELL ["cmd.exe", "/s", "/c", "C:\entrypoint.bat"]

WORKDIR /code

ENTRYPOINT ["C:\entrypoint.bat"]
CMD ["cmd"]

EXPOSE 443


og min entrypoint.bat-fil


@echo off
pushd C:
call "C:Program Files (x86)Microsoft Visual Studio2017BuildToolsCommon7ToolsVsDevCmd.bat"
REM call "C:Program Files (x86)Microsoft Visual C++ Build Toolsvcbuildtools.bat"
popd
\%*


Her er hvordan jeg bygger det


docker build -t windows .


Her er hvordan jeg kører det


docker run -it windows cmd


Sådan registrerer jeg gitlab-løberen


C:gitlab>gitlab-runner register --non-interactive --name "Windows docker builder" --url "https://gitlabserver/" --registration-token TOKEN --tag-list windows --executor shell
Registering runner... succeeded                     runner=XXX
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!


På GitLab Server kan jeg se, at det er register, men at det viser ip adressen til Windows 10 vært maskine ikke ip adressen inde i docker.
Indtast billedbeskrivelse her [6]

Bedste reference