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

Docker - sudo: sorry, you must have a tty to run sudo #2425

Closed georgevicbell closed 7 years ago

georgevicbell commented 9 years ago

It appears the docker communicator is not running exec or attach with -i -t (only the -i is passed).

There is no way to modify this behaviour.

docker/communicator.go: if c.canExec() { cmd = exec.Command("docker", "exec", "-i", c.ContainerId, "/bin/sh") } else { cmd = exec.Command("docker", "attach", c.ContainerId) }

There should be some config to allow for ptty to be turned on...

bscott commented 9 years ago

@georgevicbell @mitchellh Any idea when this will get released?, I'm running into this now with Docker/Chef Solo Provisioner

bscott commented 9 years ago
==> docker: Provisioning with chef-solo
    docker: Installing Chef...
    docker: % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
    docker: Dload  Upload   Total   Spent    Left  Speed
    docker: 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0sudo: sorry, you must have a tty to run sudo
    docker: 86 18736   86 16086    0     0  23986      0 --:--:-- --:--:-- --:--:-- 24008
    docker: curl: (23) Failed writing body (0 != 16086)
==> docker: Killing the container: dc58f05be03632523cfd7a5abc462a82a0b2c43351b99ea0326444d4eb085ccf
Build 'docker' errored: Error installing Chef: Install script exited with non-zero exit status 1

==> Some builds didn't complete successfully and had errors:
--> docker: Error installing Chef: Install script exited with non-zero exit status 1

==> Builds finished but no artifacts were created.
bscott commented 9 years ago

Found a work around by Preventing sudo with chef provisioner.

http://stackoverflow.com/questions/26694046/packer-provisioning-docker-with-chef-solo-gets-node-name-not-found-error