hashicorp / packer-plugin-docker

Packer plugin for Docker Builder
https://www.packer.io/docs/builders/docker
Mozilla Public License 2.0
30 stars 26 forks source link

Docker builder hangs when using Ansible provisioner in Docker in Docker #18

Open ghost opened 3 years ago

ghost commented 3 years ago

This issue was originally opened by @frodopwns as hashicorp/packer#3057.It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


I am running Jenkins in a Ubuntu 14.04 Docker Container.
Tried with docker 1.7.1 and 1.9.1.

The jenkins image has these volumes mounted in to allow for docker-in-docker:

-v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock

Inside this container I run a packer build with a docker builder and an ansible provisioner. This build works fine when I run it on a normal host running docker.

When run inside a docker-based jenkins image it hangs at:

==> docker: Starting docker container...
    docker: Run command: docker run -v /root/.ssh:/root/.ssh -v /etc/ansible:/etc/ansible -v /tmp/packer-docker574433279:/packer-files -d -i -t some-user/some-image /bin/bash
    docker: Container ID: 12712e6e1d7a78fef387130ff5f1f849f98333ce6eeac31e292725c5006b6355
==> docker: Provisioning with Ansible...
    docker: Creating Ansible staging directory...
    docker: Creating directory: /tmp/packer-provisioner-ansible-local

This will hang forever.

Is there a known issue with running the docker builder with ansible provisioner in a docker-in-docker environment? If so what can we do about it? Jenkins is being deployed via docker more and more often so things like packer which often get triggered by jenkins will need to run in containers.