progrium / buildstep

Buildstep uses Docker and Buildpacks to build applications like Heroku
MIT License
909 stars 273 forks source link

"tar: This does not look like a tar archive" when piping from git archive #90

Open stuartpb opened 10 years ago

stuartpb commented 10 years ago

From a Git repository where I have an app:

[stuart@stushiba laterti.me]$ git archive HEAD | sudo docker run -a stdin progrium/buildstep /bin/bash -c "mkdir -p /app && tar -xC /app"
34e3cf0bf9cbe2f0751f1c12ef473d01d41b6d54a6ca19f35b0dd8e5509ac21f
[stuart@stushiba laterti.me]$ sudo docker logs 34e3c
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors

I have no idea what's going wrong. git archive HEAD | /bin/bash -c "mkdir -p /tmp/app && tar -xC /tmp/app" on the host system works just fine, so it doesn't appear to be an issue with git archive.

stuartpb commented 10 years ago

echo foo | sudo docker run progrium/buildstep cat gives no output, wtf

And it's not sudo, this happens when run as root directly as well

stuartpb commented 10 years ago

dotcloud/docker#7142 claims adding -i should fix it, but it doesn't (dotcloud/docker#7143).

crosbymichael commented 10 years ago

How is -i not working?

libcontainer|master ⇒ git archive HEAD |  docker run -i ubuntu:14.04 /bin/bash -c "mkdir -p /app && tar -xC /app"
libcontainer|master ⇒ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
libcontainer|master ⇒ docker ps -a
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS                      PORTS               NAMES
b71dbf644fd7        ubuntu:14.04        "/bin/bash -c 'mkdir   7 seconds ago       Exited (0) 6 seconds ago                        evil_ptolemy
d34e448971fb        ubuntu:14.04        "/bin/bash -c 'mkdir   17 seconds ago      Exited (2) 16 seconds ago                       kickass_hopper
16900e8ca046        ubuntu:14.04        "bash -c 'echo start   2 minutes ago       Exited (0) 2 minutes ago                        focused_euclid
07b69fbab6c2        ubuntu:14.04        "bash -c 'echo start   2 minutes ago       Exited (0) 2 minutes ago                        cranky_nobel
libcontainer|master ⇒ docker commit b71dbf644fd7
cbbb86058a73308e95a58edcc99d01258cea6c8c5fc5f5cdea8a48230194611a
libcontainer|master ⇒ docker run -ti cbbb86058a73308e95a58edcc99d01258cea6c8c5fc5f5cdea8a48230194611a bash
root@3233cab43416:/# ls
app  bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@3233cab43416:/# cd app
root@3233cab43416:/app# ls
CONTRIBUTORS_GUIDE.md  NOTICE         apparmor        container.go  namespaces  sample_configs  system
Dockerfile             PRINCIPLES.md  cgroups         devices       netlink     security        types.go
LICENSE                README.md      config.go       factory.go    network     selinux         utils
MAINTAINERS            ROADMAP.md     config_test.go  label         nsinit      state.go
MAINTAINERS_GUIDE.md   api_temp.go    console         mount         process.go  syncpipe
root@3233cab43416:/app# exit
exit
libcontainer|master ⇒
stuartpb commented 10 years ago

It doesn't work with -a stdin. See dotcloud/docker#7143.

crosbymichael commented 10 years ago

Why are you using -a stdin in the first place?

stuartpb commented 10 years ago

See https://github.com/progrium/buildstep/blob/master/buildstep - it's to get the container ID.

crosbymichael commented 10 years ago

ok, i understand now, thanks.

progrium commented 9 years ago

This is a weird issue. I remember getting this right took a while in Docker when it was released before I could make this (and Dokku). But it does work now (as in, many people use Dokku and buildstep), so I'm curious what's special about this case?

stuartpb commented 9 years ago

It's a regression in Docker iirc: docker/docker#7143

stuartpb commented 9 years ago

Also iirc this doesn't affect Dokku because Dokku always uses -i (as does plushu-buildstep, which works around this bug by using --cidfile).

progrium commented 9 years ago

Any news/developments on this issue?

stuartpb commented 9 years ago

Ask docker/docker#7143

mjonuschat commented 9 years ago

I wonder if it could be that this is not docker related at all. The same message gets shown when the ruby buildpack can't complete the download of the requested ruby version in time (default is 30 seconds). Since curl pipes it output directly to tar there's no clean way to recover and tar sees an incomplete archive.

stuartpb commented 9 years ago

This error was definitely caused y Docker. There are other things that will cause stdin to not look like a tar archive, but not connecting it at all is the simplest of them, and different from a premature interruption. Again, see docker/docker#7143.