github.com/sams1990/dockerrepo@v17.12.1-ce-rc2+incompatible/docs/contributing/software-req-win.md (about)

     1  ### Build and test Moby on Windows
     2  
     3  This page explains how to get the software you need to build, test, and run the
     4  Moby source code for Windows and setup the required software and services:
     5  
     6  - Windows containers
     7  - GitHub account
     8  - Git
     9  
    10  ## Prerequisites
    11  
    12  ### 1. Windows Server 2016 or Windows 10 with all Windows updates applied
    13  
    14  The major build number must be at least 14393. This can be confirmed, for example,
    15  by running the following from an elevated PowerShell prompt - this sample output
    16  is from a fully up to date machine as at mid-November 2016:
    17  
    18  
    19      PS C:\> $(gin).WindowsBuildLabEx
    20      14393.447.amd64fre.rs1_release_inmarket.161102-0100
    21  
    22  ### 2. Git for Windows (or another git client) must be installed
    23  
    24  https://git-scm.com/download/win.
    25  
    26  ### 3. The machine must be configured to run containers
    27  
    28  For example, by following the quick start guidance at
    29  https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/quick_start or https://github.com/docker/labs/blob/master/windows/windows-containers/Setup.md
    30  
    31  ### 4. If building in a Hyper-V VM
    32  
    33  For Windows Server 2016 using Windows Server containers as the default option,
    34  it is recommended you have at least 1GB of memory assigned;
    35  For Windows 10 where Hyper-V Containers are employed, you should have at least
    36  4GB of memory assigned.
    37  Note also, to run Hyper-V containers in a VM, it is necessary to configure the VM
    38  for nested virtualization.
    39  
    40  ## Usage
    41  
    42  The following steps should be run from an elevated Windows PowerShell prompt.
    43  
    44  >**Note**:  In a default installation of containers on Windows following the quick-start guidance at https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/quick_start,
    45  the `docker.exe` client must run elevated to be able to connect to the daemon).
    46  
    47  ### 1. Windows containers
    48  
    49  To test and run the Windows Moby engine, you need a system that supports Windows Containers:
    50  
    51  - Windows 10 Anniversary Edition
    52  - Windows Server 2016 running in a VM, on bare metal or in the cloud
    53  
    54  Check out the [getting started documentation](https://github.com/docker/labs/blob/master/windows/windows-containers/Setup.md) for details.
    55  
    56  ### 2. GitHub account
    57  
    58  To contribute to the Docker project, you need a <a href="https://github.com" target="_blank">GitHub account</a>.
    59  A free account is fine. All the Moby project repositories are public and visible to everyone.
    60  
    61  This guide assumes that you have basic familiarity with Git and Github terminology
    62  and usage.
    63  Refer to [GitHub For Beginners: Don’t Get Scared, Get Started](http://readwrite.com/2013/09/30/understanding-github-a-journey-for-beginners-part-1/)
    64  to get up to speed on Github.
    65  
    66  ### 3. Git
    67  
    68  In PowerShell, run:
    69  
    70      Invoke-Webrequest "https://github.com/git-for-windows/git/releases/download/v2.7.2.windows.1/Git-2.7.2-64-bit.exe" -OutFile git.exe -UseBasicParsing
    71      Start-Process git.exe -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /CLOSEAPPLICATIONS /DIR=c:\git\' -Wait
    72      setx /M PATH "$env:Path;c:\git\cmd"
    73  
    74  You are now ready clone and build the Moby source code.
    75  
    76  ### 4. Clone Moby
    77  
    78  In a new (to pick up the path change) PowerShell prompt, run:
    79  
    80      git clone https://github.com/moby/moby
    81      cd moby
    82  
    83  This clones the main Moby repository. Check out [Moby Project](https://mobyproject.org)
    84  to learn about the other software that powers the Moby platform.
    85  
    86  ### 5. Build and run
    87  
    88  Create a builder-container with the Moby source code. You can change the source
    89  code on your system and rebuild any time:
    90  
    91      docker build -t nativebuildimage -f .\Dockerfile.windows .
    92      docker build -t nativebuildimage -f Dockerfile.windows -m 2GB .  # (if using Hyper-V containers)
    93  
    94  To build Moby, run:
    95  
    96      $DOCKER_GITCOMMIT=(git rev-parse --short HEAD)
    97      docker run --name binaries -e DOCKER_GITCOMMIT=$DOCKER_GITCOMMIT nativebuildimage hack\make.ps1 -Binary
    98      docker run --name binaries -e DOCKER_GITCOMMIT=$DOCKER_GITCOMMIT -m 2GB nativebuildimage hack\make.ps1 -Binary  # (if using Hyper-V containers)
    99  
   100  Copy out the resulting Windows Moby Engine binary to `dockerd.exe` in the
   101  current directory:
   102  
   103      docker cp binaries:C:\go\src\github.com\moby\moby\bundles\docker.exe docker.exe
   104      docker cp binaries:C:\go\src\github.com\moby\moby\bundles\dockerd.exe dockerd.exe
   105  
   106  To test it, stop the system Docker daemon and start the one you just built:
   107  
   108      Stop-Service Docker
   109      .\dockerd.exe -D
   110  
   111  The other make targets work too, to run unit tests try:
   112  `docker run --rm docker-builder sh -c 'cd /c/go/src/github.com/moby/moby; hack/make.sh test-unit'`.
   113  
   114  ### 6. Remove the interim binaries container
   115  
   116  _(Optional)_
   117  
   118      docker rm binaries
   119  
   120  ### 7. Remove the image
   121  
   122  _(Optional)_
   123  
   124  It may be useful to keep this image around if you need to build multiple times.
   125  Then you can take advantage of the builder cache to have an image which has all
   126  the components required to build the binaries already installed.
   127  
   128      docker rmi nativebuildimage
   129  
   130  ## Validation
   131  
   132  The validation tests can only run directly on the host.
   133  This is because they calculate information from the git repo, but the .git directory
   134  is not passed into the image as it is excluded via `.dockerignore`.
   135  Run the following from a Windows PowerShell prompt (elevation is not required):
   136  (Note Go must be installed to run these tests)
   137  
   138      hack\make.ps1 -DCO -PkgImports -GoFormat
   139  
   140  ## Unit tests
   141  
   142  To run unit tests, ensure you have created the nativebuildimage above.
   143  Then run one of the following from an (elevated) Windows PowerShell prompt:
   144  
   145      docker run --rm nativebuildimage hack\make.ps1 -TestUnit
   146      docker run --rm -m 2GB nativebuildimage hack\make.ps1 -TestUnit  # (if using Hyper-V containers)
   147  
   148  To run unit tests and binary build, ensure you have created the nativebuildimage above.
   149  Then run one of the following from an (elevated) Windows PowerShell prompt:
   150  
   151      docker run nativebuildimage hack\make.ps1 -All
   152      docker run -m 2GB nativebuildimage hack\make.ps1 -All  # (if using Hyper-V containers)
   153  
   154  ## Windows limitations
   155  
   156  Don't attempt to use a bind mount to pass a local directory as the bundles
   157  target directory.
   158  It does not work (golang attempts for follow a mapped folder incorrectly).
   159  Instead, use docker cp as per the example.
   160  
   161  `go.zip` is not removed from the image as it is used by the Windows CI servers
   162  to ensure the host and image are running consistent versions of go.
   163  
   164  Nanoserver support is a work in progress. Although the image will build if the
   165  `FROM` statement is updated, it will not work when running autogen through `hack\make.ps1`.
   166  It is suspected that the required GCC utilities (eg gcc, windres, windmc) silently
   167  quit due to the use of console hooks which are not available.
   168  
   169  The docker integration tests do not currently run in a container on Windows,
   170  predominantly due to Windows not supporting privileged mode, so anything using a volume would fail.
   171  They (along with the rest of the docker CI suite) can be run using
   172  https://github.com/jhowardmsft/docker-w2wCIScripts/blob/master/runCI/Invoke-DockerCI.ps1.
   173  
   174  ## Where to go next
   175  
   176  In the next section, you'll [learn how to set up and configure Git for
   177  contributing to Moby](set-up-git.md).