Packer and docker builder windowsservercore example

70 views
Skip to first unread message

Simon G

unread,
Mar 5, 2018, 1:49:06 PM3/5/18
to Packer
Hi,

On Windows 10, I’m trying to use packer with Windows docker builder and provision an image based on Microsoft/windowsservercore with some additions with the Powershell provisioner. Do I need to use WinRM as a communicator? I presume so.

Has anyone got any examples or can you point me to some? The docs on packer.io for docker builder are all Linux based so I’m not getting on too well. Time to ask for help!

Thanks very much for any help.

Thanks.

Rickard von Essen

unread,
Mar 5, 2018, 2:35:47 PM3/5/18
to packe...@googlegroups.com
The docker builder don't use any of the normal (SSH/WinRM) communicator. Instead it uses a custom Docker communicator. I have never tried Docker with Windows (running Windows containers) but I expect that it doesn't work. It would be really good to start an issue and make a list of all the things that needs to be fixed for this to start working, but that probably requires some experience with Docker on Windows.


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/74d615e9-19bf-42f8-9103-95d133c55ec9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Simon G

unread,
Mar 5, 2018, 6:27:14 PM3/5/18
to Packer
Hmm. Thanks for the reply. You made me feel better already! I spent days trying to figure out why it was failing to do even a basic packer docker Windows container windows build with a volume issue/error. Eventually after much trial and error I stumbled upon a set of things I tried which made it suddenly spin up a container.

I’ll document it properly but it involved setting the windows environment variable PACKER_TMP_DIR=c:\tmp but also setting Container folder in the packer docker builder segment to something like c:/app so that the packer docker run command passed (the -v parts) were then accepted. So hurdle 1 finally overcome (by guesswork) but now I want to do something/provision the image. I’m now at hurdle 2 with a C:\Windows\Temp must be a directory error.

Examples really help but I have to say I’m not finding much/any!

Simon G

unread,
Mar 6, 2018, 3:20:56 AM3/6/18
to Packer
So, just for clarity the 2nd error I'm still getting is:

==> docker2k12r2: Killing the container: 6d90ed6ff388440b4b959680ddbf42a1d5b9691dabb7fb464ff878fd2d502f46
Build 'docker2k16' errored: Error processing command: Error uploading ps script containing env vars: Failed to upload to '${env:SYSTEMROOT}\Temp\packer-env-vars-5a9d6b15-0a6a-3859-50a8-1f4f35aa695c.ps1' in container: destination "6d90ed6ff388440b4b959680ddbf42a1d5b9691dabb7fb464ff878fd2d502f46:${env:SYSTEMROOT}\Temp" must be a directory
. exit status 1.

But I'm trying to push PowerShell scripts at the moment for provisioning - so after your reply, I'll look again!

The previous error with the windows environment var was:

==> Some builds didn't complete successfully and had errors:
--> docker2k16: Error running container: Docker exited with a non-zero exit status.
Stderr: docker: Error response from daemon: invalid volume specification: 'c:/tmp/packer-docker751308459:/packer-files'.

And what seemed to fix it for me was adding the environment var PACKER_TMP_DIR=c:\tmp and also in the JSON template, you need to specifify a more windows path for the container folder:

"type": "docker",

   "image": "microsoft/windowsservercore", 

   "container_dir": "c:/app",


At least a container would spin up after setting these.  It *may* help someone else.

Regards,
Si.
Reply all
Reply to author
Forward
0 new messages