New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packer docker builder fails to run commands with talking through boot2docker #1888

Closed
mhworth opened this Issue Jan 31, 2015 · 3 comments

Comments

Projects
None yet
6 participants
@mhworth
Contributor

mhworth commented Jan 31, 2015

I am on osx and trying to build a docker image. This is my template:

{
  "builders": [{
    "type": "docker",
    "image": "ubuntu",
    "commit": true
  }], 
  "provisioners": [{
    "type": "shell",
    "inline": ["echo foo"]
  }]  
}

In order to make it so that packer and the docker images can share files, I set TMPDIR:

export TMPDIR=/Users/matt/tmp

(I'm using the latest version of boot2docker which mounts /Users in the host VM)

When I run packer build, the shell provisioner fails:

packer build test-template.json
2015/01/31 09:31:32 [INFO] Packer version: 0.7.5  9cd66feeacbd9cb318b72eb5ed59428c5b8c37ac+CHANGES
2015/01/31 09:31:32 Packer Target OS/Arch: darwin amd64
2015/01/31 09:31:32 Built with Go Version: go1.3.3
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: amazon-chroot = /Users/matt/packer/packer-builder-amazon-chroot
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: amazon-ebs = /Users/matt/packer/packer-builder-amazon-ebs
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: amazon-instance = /Users/matt/packer/packer-builder-amazon-instance
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: digitalocean = /Users/matt/packer/packer-builder-digitalocean
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: docker = /Users/matt/packer/packer-builder-docker
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: googlecompute = /Users/matt/packer/packer-builder-googlecompute
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: null = /Users/matt/packer/packer-builder-null
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: openstack = /Users/matt/packer/packer-builder-openstack
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: parallels-iso = /Users/matt/packer/packer-builder-parallels-iso
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: parallels-pvm = /Users/matt/packer/packer-builder-parallels-pvm
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: qemu = /Users/matt/packer/packer-builder-qemu
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: virtualbox-iso = /Users/matt/packer/packer-builder-virtualbox-iso
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: virtualbox-ovf = /Users/matt/packer/packer-builder-virtualbox-ovf
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: vmware-iso = /Users/matt/packer/packer-builder-vmware-iso
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: vmware-vmx = /Users/matt/packer/packer-builder-vmware-vmx
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: atlas = /Users/matt/packer/packer-post-processor-atlas
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: compress = /Users/matt/packer/packer-post-processor-compress
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: docker-import = /Users/matt/packer/packer-post-processor-docker-import
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: docker-push = /Users/matt/packer/packer-post-processor-docker-push
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: docker-save = /Users/matt/packer/packer-post-processor-docker-save
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: docker-tag = /Users/matt/packer/packer-post-processor-docker-tag
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: vagrant = /Users/matt/packer/packer-post-processor-vagrant
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: vagrant-cloud = /Users/matt/packer/packer-post-processor-vagrant-cloud
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: vsphere = /Users/matt/packer/packer-post-processor-vsphere
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: ansible-local = /Users/matt/packer/packer-provisioner-ansible-local
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: chef-client = /Users/matt/packer/packer-provisioner-chef-client
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: chef-solo = /Users/matt/packer/packer-provisioner-chef-solo
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: file = /Users/matt/packer/packer-provisioner-file
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: puppet-masterless = /Users/matt/packer/packer-provisioner-puppet-masterless
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: puppet-server = /Users/matt/packer/packer-provisioner-puppet-server
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: salt-masterless = /Users/matt/packer/packer-provisioner-salt-masterless
2015/01/31 09:31:32 [DEBUG] Discoverd plugin: shell = /Users/matt/packer/packer-provisioner-shell
2015/01/31 09:31:32 Detected home directory from env var: /Users/matt
2015/01/31 09:31:32 Detected home directory from env var: /Users/matt
2015/01/31 09:31:32 Attempting to open config file: /Users/matt/.packerconfig
2015/01/31 09:31:32 File doesn't exist, but doesn't need to. Ignoring.
2015/01/31 09:31:32 Packer config: &{DisableCheckpoint:false DisableCheckpointSignature:false PluginMinPort:10000 PluginMaxPort:25000 Builders:map[amazon-chroot:/Users/matt/packer/packer-builder-amazon-chroot digitalocean:/Users/matt/packer/packer-builder-digitalocean qemu:/Users/matt/packer/packer-builder-qemu virtualbox-iso:/Users/matt/packer/packer-builder-virtualbox-iso vmware-iso:/Users/matt/packer/packer-builder-vmware-iso amazon-instance:/Users/matt/packer/packer-builder-amazon-instance parallels-pvm:/Users/matt/packer/packer-builder-parallels-pvm amazon-ebs:/Users/matt/packer/packer-builder-amazon-ebs googlecompute:/Users/matt/packer/packer-builder-googlecompute null:/Users/matt/packer/packer-builder-null openstack:/Users/matt/packer/packer-builder-openstack parallels-iso:/Users/matt/packer/packer-builder-parallels-iso docker:/Users/matt/packer/packer-builder-docker virtualbox-ovf:/Users/matt/packer/packer-builder-virtualbox-ovf vmware-vmx:/Users/matt/packer/packer-builder-vmware-vmx] PostProcessors:map[compress:/Users/matt/packer/packer-post-processor-compress docker-import:/Users/matt/packer/packer-post-processor-docker-import vagrant:/Users/matt/packer/packer-post-processor-vagrant vagrant-cloud:/Users/matt/packer/packer-post-processor-vagrant-cloud vsphere:/Users/matt/packer/packer-post-processor-vsphere atlas:/Users/matt/packer/packer-post-processor-atlas docker-push:/Users/matt/packer/packer-post-processor-docker-push docker-save:/Users/matt/packer/packer-post-processor-docker-save docker-tag:/Users/matt/packer/packer-post-processor-docker-tag] Provisioners:map[shell:/Users/matt/packer/packer-provisioner-shell ansible-local:/Users/matt/packer/packer-provisioner-ansible-local chef-client:/Users/matt/packer/packer-provisioner-chef-client chef-solo:/Users/matt/packer/packer-provisioner-chef-solo file:/Users/matt/packer/packer-provisioner-file puppet-masterless:/Users/matt/packer/packer-provisioner-puppet-masterless puppet-server:/Users/matt/packer/packer-provisioner-puppet-server salt-masterless:/Users/matt/packer/packer-provisioner-salt-masterless]}
2015/01/31 09:31:32 Detected home directory from env var: /Users/matt
2015/01/31 09:31:32 Setting cache directory: /Users/matt/dev/packer-test/packer_cache
2015/01/31 09:31:32 Reading template: test-template.json
2015/01/31 09:31:32 Creating build: docker
2015/01/31 09:31:32 Loading builder: docker
2015/01/31 09:31:32 Creating plugin client for path: /Users/matt/packer/packer-builder-docker
2015/01/31 09:31:32 Starting plugin: /Users/matt/packer/packer-builder-docker []string{"/Users/matt/packer/packer-builder-docker"}
2015/01/31 09:31:32 Waiting for RPC address for: /Users/matt/packer/packer-builder-docker
2015/01/31 09:31:32 packer-builder-docker: 2015/01/31 09:31:32 Plugin minimum port: 10000
2015/01/31 09:31:32 packer-builder-docker: 2015/01/31 09:31:32 Plugin maximum port: 25000
2015/01/31 09:31:32 packer-builder-docker: 2015/01/31 09:31:32 Plugin address: unix /Users/matt/tmp/packer-plugin082213353
2015/01/31 09:31:32 packer-builder-docker: 2015/01/31 09:31:32 Waiting for connection...
2015/01/31 09:31:32 packer-builder-docker: 2015/01/31 09:31:32 Serving a plugin connection...
2015/01/31 09:31:32 Loading provisioner: shell
2015/01/31 09:31:32 Creating plugin client for path: /Users/matt/packer/packer-provisioner-shell
2015/01/31 09:31:32 Starting plugin: /Users/matt/packer/packer-provisioner-shell []string{"/Users/matt/packer/packer-provisioner-shell"}
2015/01/31 09:31:32 Waiting for RPC address for: /Users/matt/packer/packer-provisioner-shell
2015/01/31 09:31:32 packer-provisioner-shell: 2015/01/31 09:31:32 Plugin minimum port: 10000
2015/01/31 09:31:32 packer-provisioner-shell: 2015/01/31 09:31:32 Plugin maximum port: 25000
2015/01/31 09:31:32 packer-provisioner-shell: 2015/01/31 09:31:32 Plugin address: unix /Users/matt/tmp/packer-plugin656258990
2015/01/31 09:31:32 packer-provisioner-shell: 2015/01/31 09:31:32 Waiting for connection...
2015/01/31 09:31:32 packer-provisioner-shell: 2015/01/31 09:31:32 Serving a plugin connection...
2015/01/31 09:31:32 ui: docker output will be in this color.
2015/01/31 09:31:32 ui: 
2015/01/31 09:31:32 Build debug mode: false
2015/01/31 09:31:32 Force build: false
2015/01/31 09:31:32 Preparing build: docker
docker output will be in this color.

2015/01/31 09:31:32 Waiting on builds to complete...
2015/01/31 09:31:32 Starting build run: docker
2015/01/31 09:31:32 Running builder: docker
2015/01/31 09:31:32 ui: ==> docker: Creating a temporary directory for sharing data...
==> docker: Creating a temporary directory for sharing data...
2015/01/31 09:31:32 ui: ==> docker: Pulling Docker image: ubuntu
==> docker: Pulling Docker image: ubuntu
2015/01/31 09:31:32 packer-builder-docker: 2015/01/31 09:31:32 Executing: /usr/local/bin/docker [pull ubuntu]
2015/01/31 09:31:33 ui:     docker: ubuntu:latest: The image you are pulling has been verified
    docker: ubuntu:latest: The image you are pulling has been verified
2015/01/31 09:31:33 ui:     docker: 511136ea3c5a: Already exists
    docker: 511136ea3c5a: Already exists
2015/01/31 09:31:33 ui:     docker: 27d47432a69b: Already exists
    docker: 27d47432a69b: Already exists
2015/01/31 09:31:33 ui:     docker: 5f92234dcf1e: Already exists
    docker: 5f92234dcf1e: Already exists
2015/01/31 09:31:33 ui:     docker: 51a9c7c1f8bb: Already exists
    docker: 51a9c7c1f8bb: Already exists
2015/01/31 09:31:33 ui:     docker: 5ba9dab47459: Already exists
2015/01/31 09:31:33 ui:     docker: Status: Image is up to date for ubuntu:latest
    docker: 5ba9dab47459: Already exists
    docker: Status: Image is up to date for ubuntu:latest
2015/01/31 09:31:33 ui: ==> docker: Starting docker container...
==> docker: Starting docker container...
2015/01/31 09:31:33 ui:     docker: Run command: docker run -v /Users/matt/tmp/packer-docker321355316:/packer-files -d -i -t ubuntu /bin/bash
2015/01/31 09:31:33 packer-builder-docker: 2015/01/31 09:31:33 Starting container with args: [run -v /Users/matt/tmp/packer-docker321355316:/packer-files -d -i -t ubuntu /bin/bash]
    docker: Run command: docker run -v /Users/matt/tmp/packer-docker321355316:/packer-files -d -i -t ubuntu /bin/bash
2015/01/31 09:31:33 packer-builder-docker: 2015/01/31 09:31:33 Waiting for container to finish starting
2015/01/31 09:31:33 ui:     docker: Container ID: 33b96470e1807e52eabcb963d74d828ca54cee809fac1eb3a9524c9495748176
2015/01/31 09:31:33 packer-builder-docker: 2015/01/31 09:31:33 Running the provision hook
    docker: Container ID: 33b96470e1807e52eabcb963d74d828ca54cee809fac1eb3a9524c9495748176
2015/01/31 09:31:33 ui: ==> docker: Provisioning with shell script: /Users/matt/tmp/packer-shell836506421
==> docker: Provisioning with shell script: /Users/matt/tmp/packer-shell836506421
2015/01/31 09:31:33 packer-provisioner-shell: 2015/01/31 09:31:33 Opening /Users/matt/tmp/packer-shell836506421 for reading
2015/01/31 09:31:33 packer-provisioner-shell: 2015/01/31 09:31:33 [INFO] 19 bytes written for 'uploadData'
2015/01/31 09:31:33 [INFO] 19 bytes written for 'uploadData'
2015/01/31 09:31:33 packer-builder-docker: 2015/01/31 09:31:33 Executing in container 33b96470e1807e52eabcb963d74d828ca54cee809fac1eb3a9524c9495748176: "(cp /packer-files/upload154290691 /tmp/script.sh) >/packer-files/cmd696409990 2>&1; echo $? >/packer-files/cmd696409990-exit"
2015/01/31 09:31:35 packer-provisioner-shell: 2015/01/31 09:31:35 Retryable error: Error uploading script: Upload failed with non-zero exit status: 1
2015/01/31 09:31:37 packer-provisioner-shell: 2015/01/31 09:31:37 [INFO] 19 bytes written for 'uploadData'
2015/01/31 09:31:37 [INFO] 19 bytes written for 'uploadData'
2015/01/31 09:31:37 packer-builder-docker: 2015/01/31 09:31:37 Executing in container 33b96470e1807e52eabcb963d74d828ca54cee809fac1eb3a9524c9495748176: "(cp /packer-files/upload193688365 /tmp/script.sh) >/packer-files/cmd714548904 2>&1; echo $? >/packer-files/cmd714548904-exit"
2015/01/31 09:31:39 packer-provisioner-shell: 2015/01/31 09:31:39 Retryable error: Error uploading script: Upload failed with non-zero exit status: 1
2015/01/31 09:31:41 packer-provisioner-shell: 2015/01/31 09:31:41 [INFO] 19 bytes written for 'uploadData'
2015/01/31 09:31:41 [INFO] 19 bytes written for 'uploadData'
...

It just keeps retrying forever. If I attach to the process myself, the temp files are available:

root@33b96470e180:/# cat /packer-files/*
#!/bin/sh
echo foo

The same thing happens if I try to use the salt provisioner. Any idea what could cause this?

Note: This thread seems relevant, https://groups.google.com/forum/#!msg/packer-tool/v_9yTv-UNHI/j4VLQ8RfZ0IJ

@nicck

This comment has been minimized.

Show comment
Hide comment
@nicck

nicck Feb 18, 2015

I have same issue without boot2docker.

{
  "builders": [{
    "type": "docker",
    "image": "ubuntu",
    "export_path": "image.tar"
  }],
  "provisioners": [{
    "type": "shell",
    "inline": [
      "echo foo"
    ]
  }]
}

/tmp/packer-log....

...
2015/02/18 11:49:11 packer-builder-docker: 2015/02/18 11:49:11 Executing in container df9fdf9896ed2179f1edaff6f6729b6fd1eb423a6f8d6c16d71cfa6f80626623: "(cp /packer-files/upload676514484 /tmp/script.sh) >/packer-files/cmd284882563 2>&1; echo $? >/packer-files/cmd284882563-exit"
2015/02/18 11:49:13 packer-provisioner-shell: 2015/02/18 11:49:13 Retryable error: Error uploading script: Upload failed with non-zero exit status: 1
2015/02/18 11:49:15 packer-provisioner-shell: 2015/02/18 11:49:15 [INFO] 19 bytes written for 'uploadData'
2015/02/18 11:49:15 [INFO] 19 bytes written for 'uploadData'
2015/02/18 11:49:15 packer-builder-docker: 2015/02/18 11:49:15 Executing in container df9fdf9896ed2179f1edaff6f6729b6fd1eb423a6f8d6c16d71cfa6f80626623: "(cp /packer-files/upload707832326 /tmp/script.sh) >/packer-files/cmd597766061 2>&1; echo $? >/packer-files/cmd597766061-exit"
2015/02/18 11:49:17 packer-provisioner-shell: 2015/02/18 11:49:17 Retryable error: Error uploading script: Upload failed with non-zero exit status: 1
2015/02/18 11:49:19 packer-provisioner-shell: 2015/02/18 11:49:19 [INFO] 19 bytes written for 'uploadData'
...

nicck commented Feb 18, 2015

I have same issue without boot2docker.

{
  "builders": [{
    "type": "docker",
    "image": "ubuntu",
    "export_path": "image.tar"
  }],
  "provisioners": [{
    "type": "shell",
    "inline": [
      "echo foo"
    ]
  }]
}

/tmp/packer-log....

...
2015/02/18 11:49:11 packer-builder-docker: 2015/02/18 11:49:11 Executing in container df9fdf9896ed2179f1edaff6f6729b6fd1eb423a6f8d6c16d71cfa6f80626623: "(cp /packer-files/upload676514484 /tmp/script.sh) >/packer-files/cmd284882563 2>&1; echo $? >/packer-files/cmd284882563-exit"
2015/02/18 11:49:13 packer-provisioner-shell: 2015/02/18 11:49:13 Retryable error: Error uploading script: Upload failed with non-zero exit status: 1
2015/02/18 11:49:15 packer-provisioner-shell: 2015/02/18 11:49:15 [INFO] 19 bytes written for 'uploadData'
2015/02/18 11:49:15 [INFO] 19 bytes written for 'uploadData'
2015/02/18 11:49:15 packer-builder-docker: 2015/02/18 11:49:15 Executing in container df9fdf9896ed2179f1edaff6f6729b6fd1eb423a6f8d6c16d71cfa6f80626623: "(cp /packer-files/upload707832326 /tmp/script.sh) >/packer-files/cmd597766061 2>&1; echo $? >/packer-files/cmd597766061-exit"
2015/02/18 11:49:17 packer-provisioner-shell: 2015/02/18 11:49:17 Retryable error: Error uploading script: Upload failed with non-zero exit status: 1
2015/02/18 11:49:19 packer-provisioner-shell: 2015/02/18 11:49:19 [INFO] 19 bytes written for 'uploadData'
...
@indygreg

This comment has been minimized.

Show comment
Hide comment
@indygreg

indygreg Mar 9, 2015

I would suggest packer upload an explicit archive/context to the builder environment instead of attempting host-based volume mounting. There is far less that can go wrong with this approach. I've learned from experience.

indygreg commented Mar 9, 2015

I would suggest packer upload an explicit archive/context to the builder environment instead of attempting host-based volume mounting. There is far less that can go wrong with this approach. I've learned from experience.

@rsmitty

This comment has been minimized.

Show comment
Hide comment
@rsmitty

rsmitty May 8, 2015

I'm encountering this issue as well with my Mac. I'm trying to use docker-machine with a local boot2docker host. This issue seems related: #1752

rsmitty commented May 8, 2015

I'm encountering this issue as well with my Mac. I'm trying to use docker-machine with a local boot2docker host. This issue seems related: #1752

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment