Skip to content

Instantly share code, notes, and snippets.

@garthk
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garthk/9107359 to your computer and use it in GitHub Desktop.
Save garthk/9107359 to your computer and use it in GitHub Desktop.

stdin handling bug

First, build the image:

docker build -rm -t logstash.ZGJFs18d .

Ensure all your stdin is passed to the process in the container:

seq 1 10 | docker run -rm -i logstash.ZGJFs18d wc -l

Expected output: 10

Ensure you can run seq 1 10 through logstash-noconfig:

docker run -rm -i logstash.ZGJFs18d seqtest

The script simply runs Logstash 1.3.3 without a configuration:

java -jar logstash-1.3.3-flatjar.jar agent -e ''

Expected output:

{
       "message" => "1",
      "@version" => "1",
    "@timestamp" => "2014-02-20T05:00:53.699Z",
          "type" => "stdin",
          "host" => "1ebabc819b6f"
}
...
{
       "message" => "10",
      "@version" => "1",
    "@timestamp" => "2014-02-20T05:00:53.704Z",
          "type" => "stdin",
          "host" => "1ebabc819b6f"
}

Now, try running seq outside the container:

seq 1 10 | docker run -rm -i logstash.ZGJFs18d logstash-noconfig

That works fine on a native Docker with a domain socket, but not if you're on OS X talking to the boot2docker image via DOCKER_HOST=tcp://.

docker version:

Client version: 0.8.0
Go version (client): go1.2
Git commit (client): cc3a8c8
Server version: 0.8.0
Git commit (server): cc3a8c8
Go version (server): go1.2

docker info:

Containers: 17
Images: 86
Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Dirs: 150
Debug mode (server): true
Debug mode (client): false
Fds: 15
Goroutines: 43
Execution Driver: lxc-0.8.0
EventsListeners: 71
Kernel Version: 3.12.1-tinycore64
Init Path: /usr/local/bin/docker
FROM stackbrew/ubuntu:precise
MAINTAINER Garth Kidd <garth@garthk.com>
ENV DEBIAN_FRONTEND noninteractive
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
RUN dpkg-divert --local --rename /usr/bin/ischroot && ln -sf /bin/true /usr/bin/ischroot
RUN apt-get update
RUN apt-get install -y openjdk-6-jdk curl
RUN cd /opt && curl -OL https://download.elasticsearch.org/logstash/logstash/logstash-1.3.3-flatjar.jar
ADD logstash-noconfig /usr/local/bin/
ADD seqtest /usr/local/bin/
RUN chmod a+x /usr/local/bin/logstash-noconfig /usr/local/bin/seqtest
#!/bin/sh
# run logstash without any config == dump stdin to stdout at records
/usr/bin/env java -jar /opt/logstash-1.3.3-flatjar.jar agent -e ''
#!/bin/sh
# feed ten lines through logstash-noconfig
seq 1 10 | logstash-noconfig
@SvenDowideit
Copy link

depressingly, it works for me on boot2docker 0.5.4 running on bare hardware

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