hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.09k stars 3.33k forks source link

chef-solo just hangs for docker #1308

Closed treyhyde closed 10 years ago

treyhyde commented 10 years ago

The chef-solo provisioner just hangs. I've tried this with a few different images including ubuntu:14.04 and learn/tutorial. I've tried overriding install_command but that doesn't help

I'm very new to docker but something looks a little odd with InstallCommand and ExecuteCommand. It appears to me that docker run doesn't actually execute in a shell and so using commands with shell operators like | and > don't work as expected. Regardless, I've been unable to get beyond InstallCommand. The system is idle while it is waiting forever for InstallCommand to return.

{
    "builders":[{
        "type": "docker",
        "image": "learn/tutorial",
        "export_path": "image.tar"
    }],
    "provisioners":[
    {
  "type": "chef-solo",
  "cookbook_paths": ["cookbooks"],
  "run_list" : ["test::default"]
}
    ]
}
2014/06/30 20:56:42 /usr/local/bin/packer-command-build: 2014/06/30 20:56:42 Force build: false
2014/06/30 20:56:42 /usr/local/bin/packer-command-build: 2014/06/30 20:56:42 Preparing build: docker
2014/06/30 20:56:42 /usr/local/bin/packer-command-build: 2014/06/30 20:56:42 Waiting on builds to complete...
2014/06/30 20:56:42 /usr/local/bin/packer-command-build: 2014/06/30 20:56:42 Starting build run: docker
2014/06/30 20:56:42 /usr/local/bin/packer-command-build: 2014/06/30 20:56:42 Running builder: docker
==> docker: Creating a temporary directory for sharing data...
2014/06/30 20:56:42 ui: ==> docker: Creating a temporary directory for sharing data...
==> docker: Pulling Docker image: learn/tutorial
2014/06/30 20:56:42 ui: ==> docker: Pulling Docker image: learn/tutorial
2014/06/30 20:56:42 /usr/local/bin/packer-builder-docker: 2014/06/30 20:56:42 Executing: /usr/local/bin/docker [pull learn/tutorial]
    docker: Pulling repository learn/tutorial
2014/06/30 20:56:42 ui:     docker: Pulling repository learn/tutorial
==> docker: Starting docker container...
2014/06/30 20:56:45 ui: ==> docker: Starting docker container...
    docker: Run command: docker run -d -i -t -v /var/folders/kg/3_d5pggn1n3gk62swrvv71ph0000gp/T/packer-docker422951514:/packer-files learn/tutorial /bin/bash
2014/06/30 20:56:45 ui:     docker: Run command: docker run -d -i -t -v /var/folders/kg/3_d5pggn1n3gk62swrvv71ph0000gp/T/packer-docker422951514:/packer-files learn/tutorial /bin/bash
2014/06/30 20:56:45 /usr/local/bin/packer-builder-docker: 2014/06/30 20:56:45 Starting container with args: [run -d -i -t -v /var/folders/kg/3_d5pggn1n3gk62swrvv71ph0000gp/T/packer-docker422951514:/packer-files learn/tutorial /bin/bash]
2014/06/30 20:56:45 /usr/local/bin/packer-builder-docker: 2014/06/30 20:56:45 Waiting for container to finish starting
    docker: Container ID: 28fb4ed3141dbe9d5d10547922cee365da2bedf2c80d31dc9b99bbae9bc9e418
2014/06/30 20:56:45 ui:     docker: Container ID: 28fb4ed3141dbe9d5d10547922cee365da2bedf2c80d31dc9b99bbae9bc9e418
2014/06/30 20:56:45 /usr/local/bin/packer-builder-docker: 2014/06/30 20:56:45 Running the provision hook
==> docker: Provisioning with chef-solo
2014/06/30 20:56:45 ui: ==> docker: Provisioning with chef-solo
    docker: Installing Chef...
2014/06/30 20:56:45 ui:     docker: Installing Chef...
2014/06/30 20:56:45 /usr/local/bin/packer-builder-docker: 2014/06/30 20:56:45 Executing in container 28fb4ed3141dbe9d5d10547922cee365da2bedf2c80d31dc9b99bbae9bc9e418: "(curl -L https://www.opscode.com/chef/install.sh | sudo bash) >/packer-files/cmd192455153 2>&1; echo $? >/packer-files/cmd192455153-exit"
2014/06/30 20:56:47 /usr/local/bin/packer-builder-docker: 2014/06/30 20:56:47 Waiting for exit code to appear for remote command...

$ docker ps -l
CONTAINER ID        IMAGE                   COMMAND             CREATED             STATUS              PORTS               NAMES
28fb4ed3141d        learn/tutorial:latest   /bin/bash           2 minutes ago       Up 2 minutes                            elegant_torvalds    

$ docker logs 28fb4ed3141d
h) >/packer-files/cmd192455153 2>&1; echo $? >/packer-files/cmd192455153-exitbas 
treasonx commented 10 years ago

I am experiencing the same issue.

mitchellh commented 10 years ago

I ran your exact command and this looks to be fixed.