From b079d7ba1210872919e8531c6883d23129f56d9f Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 29 Mar 2019 13:39:02 -0700 Subject: [PATCH] add windows container example --- website/source/docs/builders/docker.html.md | 34 +++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/website/source/docs/builders/docker.html.md b/website/source/docs/builders/docker.html.md index c7384ae3a..83726aa33 100644 --- a/website/source/docs/builders/docker.html.md +++ b/website/source/docs/builders/docker.html.md @@ -210,8 +210,11 @@ You must specify (only) one of `commit`, `discard`, or `export_path`. - `run_command` (array of strings) - An array of arguments to pass to `docker run` in order to run the container. By default this is set to - `["-d", "-i", "-t", "{{.Image}}", "/bin/sh"]`. As you can see, you have a - couple template variables to customize, as well. + `["-d", "-i", "-t", "--entrypoint=/bin/sh", "--", "{{.Image}}"]` if you are + using a linux container, and + `["-d", "-i", "-t", "--entrypoint=powershell", "--", "{{.Image}}"]` if you + are running a windows container. {{.Image}} is a template variable that + corresponds to the `image` template option. - `volumes` (map of strings to strings) - A mapping of additional volumes to mount into this container. The key of the object is the host path, the @@ -338,6 +341,33 @@ nearly-identical sequence definitions, as demonstrated by the example below: +## Docker For Windows + +You should be able to run docker builds against both linux and Windows +containers. Windows containers use a different communicator than linux +containers, because Windows containers cannot use `docker cp`. + +If you are building a Windows container, you must set the template option +`"windows_container": true`. Please note that docker cannot export Windows +containers, so you must either commit or discard them. + +The following is a fully functional template for building a Windows +container. + +``` json +{ + "builders": [ + { + "type": "docker", + "image": "microsoft/windowsservercore:1709", + "container_dir": "c:/app", + "windows_container": true, + "commit": true + } + ] +} +``` + ## Amazon EC2 Container Registry Packer can tag and push images for use in [Amazon EC2 Container