github.com/nullne/docker@v1.13.0-rc1/Dockerfile.windows (about) 1 # escape=` 2 3 # ----------------------------------------------------------------------------------------- 4 # This file describes the standard way to build Docker in a container on Windows 5 # Server 2016. 6 # 7 # Maintainer: @jhowardmsft 8 # ----------------------------------------------------------------------------------------- 9 10 11 # Prerequisites: 12 # -------------- 13 # 14 # 1. Windows Server 2016 with all Windows updates applied. Pre-release versions 15 # of Windows are not supported (eg Windows Server 2016 TP5). The build number 16 # must be at least 14393. This can be confirmed, for example, by running the 17 # following from an elevated PowerShell prompt - this sample output is from a 18 # fully up to date machine as at late October 2016: 19 # 20 # >> PS C:\> $(gin).WindowsBuildLabEx 21 # >> 14393.321.amd64fre.rs1_release_inmarket.161004-2338 22 # 23 # 2. Git for Windows (or another git client) must be installed. https://git-scm.com/download/win. 24 # 25 # 3. The machine must be configured to run containers. For example, by following 26 # the quick start guidance at https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/quick_start or 27 # https://github.com/docker/labs/blob/master/windows/windows-containers/Setup.md 28 29 30 # ----------------------------------------------------------------------------------------- 31 32 33 # Usage: 34 # ----- 35 # 36 # The following steps should be run from an (elevated*) Windows PowerShell prompt. 37 # 38 # (*In a default installation of containers on Windows following the quick-start guidance at 39 # https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/quick_start, 40 # the docker.exe client must run elevated to be able to connect to the daemon). 41 # 42 # 1. Clone the sources from github.com: 43 # 44 # >> git clone https://github.com/docker/docker.git C:\go\src\github.com\docker\docker 45 # >> Cloning into 'C:\go\src\github.com\docker\docker'... 46 # >> remote: Counting objects: 186216, done. 47 # >> remote: Compressing objects: 100% (21/21), done. 48 # >> remote: Total 186216 (delta 5), reused 0 (delta 0), pack-reused 186195 49 # >> Receiving objects: 100% (186216/186216), 104.32 MiB | 8.18 MiB/s, done. 50 # >> Resolving deltas: 100% (123139/123139), done. 51 # >> Checking connectivity... done. 52 # >> Checking out files: 100% (3912/3912), done. 53 # >> PS C:\> 54 # 55 # 56 # 2. Change directory to the cloned docker sources: 57 # 58 # >> cd C:\go\src\github.com\docker\docker 59 # 60 # 61 # 3. Build a docker image with the components required to build the docker binaries from source: 62 # 63 # >> docker build -t nativebuildimage -f Dockerfile.windows . 64 # 65 # 66 # 4. Build the docker executable binaries in a container: 67 # 68 # >> docker run --name binaries nativebuildimage sh -c 'cd /c/go/src/github.com/docker/docker; hack/make.sh binary' 69 # 70 # 71 # 5. Copy the binaries out of the above container, replacing HostPath with an appropriate destination 72 # folder on the host system where you want the binaries to be located. 73 # 74 # >> $v=$(Get-Content ".\VERSION" -raw).ToString().Replace("`n","").Trim() 75 # >> docker cp binaries:C:\go\src\github.com\docker\docker\bundles\$v\binary-client\docker-$v.exe C:\HostPath\docker.exe 76 # >> docker cp binaries:C:\go\src\github.com\docker\docker\bundles\$v\binary-daemon\dockerd.exe C:\HostPath\dockerd.exe 77 # >> docker cp binaries:C:\go\src\github.com\docker\docker\bundles\$v\binary-daemon\docker-proxy-$v.exe C:\HostPath\docker-proxy.exe 78 # 79 # 80 # 6. (Optional) Remove the interim container holding the built executable binaries: 81 # 82 # >> docker rm binaries 83 # 84 # 85 # 7. (Optional) Remove the image used for the container in which the executable 86 # binaries are build. Tip - it may be useful to keep this image around if you need to 87 # build multiple times. Then you can take advantage of the builder cache to have an 88 # image which has all the components required to build the binaries already installed. 89 # 90 # >> docker rmi nativebuildimage 91 92 93 # ----------------------------------------------------------------------------------------- 94 95 96 # Important notes: 97 # --------------- 98 # 99 # The posix utilities from git aren't usable interactively as at October 2016. This 100 # is because they require a console window which isn't present in a container in Windows. 101 # See the example at the top of this file. Do NOT use -it in that docker run. It will not work. 102 # 103 # Don't attempt to use a volume for passing the source through to the container. The posix utilities will 104 # balk at reparse points. 105 # 106 # The downloaded files are not cleared from the image. go.zip is used by the Windows 107 # CI servers to ensure the host and image are running consistent versions of go. 108 # 109 # The GIT installer isn't very good at unattended install. We use techniques described 110 # at the links below to force it to set the path and other options accordingly. 111 # >> http://superuser.com/questions/944576/git-for-windows-silent-install-silent-arguments 112 # and follow through to installer at 113 # >> https://github.com/ferventcoder/chocolatey-packages/blob/master/automatic/git.install/tools/chocolateyInstall.ps1 114 # 115 # As of October 2016, this does not work on Windows 10 client, just Windows Server 2016, 116 # and only with the default isolation mode (process). It does not work with isolation mode 117 # set to Hyper-V containers (hyperv). 118 119 # ----------------------------------------------------------------------------------------- 120 121 # The number of build steps below are explicitly minimised to improve performance. 122 FROM microsoft/windowsservercore 123 124 # Use PowerShell as the default shell 125 SHELL ["powershell", "-command"] 126 127 # Environment variable notes: 128 # - GO_VERSION must be consistent with 'Dockerfile' used by Linux. 129 # - FROM_DOCKERFILE is used for detection of building within a container. 130 ENV GO_VERSION=1.7.3 ` 131 GIT_LOCATION=https://github.com/git-for-windows/git/releases/download/v2.10.1.windows.1/Git-2.10.1-64-bit.exe ` 132 GOPATH=C:\go ` 133 FROM_DOCKERFILE=1 134 135 WORKDIR C:\ 136 137 RUN ` 138 setx /M Path $($Env:PATH+';C:\gcc\bin;C:\go\bin'); ` 139 ` 140 $ErrorActionPreference = 'Stop'; ` 141 Function Download-File([string] $source, [string] $target) { ` 142 $wc = New-Object net.webclient; $wc.Downloadfile($source, $target) ` 143 } ` 144 ` 145 Write-Host INFO: Downloading git...; ` 146 Download-File $Env:GIT_LOCATION gitsetup.exe; ` 147 ` 148 Write-Host INFO: Downloading go...; ` 149 Download-File $('https://golang.org/dl/go'+$Env:GO_VERSION+'.windows-amd64.zip') go.zip; ` 150 ` 151 Write-Host INFO: Downloading compiler 1 of 3...; ` 152 Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/gcc.zip gcc.zip; ` 153 ` 154 Write-Host INFO: Downloading compiler 2 of 3...; ` 155 Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/runtime.zip runtime.zip; ` 156 ` 157 Write-Host INFO: Downloading compiler 3 of 3...; ` 158 Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/binutils.zip binutils.zip; ` 159 ` 160 Write-Host INFO: Installing git...; ` 161 $installPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'; ` 162 $installItem = 'Git_is1'; ` 163 New-Item -Path $installPath -Name $installItem -Force; ` 164 $installKey = $installPath+'\'+$installItem; ` 165 New-ItemProperty $installKey -Name 'Inno Setup CodeFile: Path Option' -Value 'CmdTools' -PropertyType 'String' -Force; ` 166 New-ItemProperty $installKey -Name 'Inno Setup CodeFile: Bash Terminal Option' -Value 'ConHost' -PropertyType 'String' -Force; ` 167 New-ItemProperty $installKey -Name 'Inno Setup CodeFile: CRLF Option' -Value 'CRLFCommitAsIs' -PropertyType 'String' -Force; ` 168 Start-Process gitsetup.exe -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /CLOSEAPPLICATIONS /DIR=C:\git\' -Wait; ` 169 ` 170 Write-Host INFO: Expanding go...; ` 171 Expand-Archive C:\go.zip -DestinationPath C:\; ` 172 ` 173 Write-Host INFO: Expanding compiler...; ` 174 Expand-Archive C:\gcc.zip -DestinationPath C:\gcc -Force; ` 175 Expand-Archive C:\runtime.zip -DestinationPath C:\gcc -Force; ` 176 Expand-Archive C:\binutils.zip -DestinationPath C:\gcc -Force; ` 177 ` 178 Write-Host INFO: Completed 179 180 # Prepare for building 181 COPY . C:\go\src\github.com\docker\docker 182