{"action":"closed","number":110,"pull_request":{"url":"https://api.github.com/repos/spotify/docker-client/pulls/110","id":26385801,"html_url":"https://github.com/spotify/docker-client/pull/110","diff_url":"https://github.com/spotify/docker-client/pull/110.diff","patch_url":"https://github.com/spotify/docker-client/pull/110.patch","issue_url":"https://api.github.com/repos/spotify/docker-client/issues/110","number":110,"state":"closed","locked":false,"title":"Attach stdout and stderr as streams to LogStream","user":{"login":"JWGmeligMeyling","id":3469492,"avatar_url":"https://avatars.githubusercontent.com/u/3469492?v=3","gravatar_id":"","url":"https://api.github.com/users/JWGmeligMeyling","html_url":"https://github.com/JWGmeligMeyling","followers_url":"https://api.github.com/users/JWGmeligMeyling/followers","following_url":"https://api.github.com/users/JWGmeligMeyling/following{/other_user}","gists_url":"https://api.github.com/users/JWGmeligMeyling/gists{/gist_id}","starred_url":"https://api.github.com/users/JWGmeligMeyling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JWGmeligMeyling/subscriptions","organizations_url":"https://api.github.com/users/JWGmeligMeyling/orgs","repos_url":"https://api.github.com/users/JWGmeligMeyling/repos","events_url":"https://api.github.com/users/JWGmeligMeyling/events{/privacy}","received_events_url":"https://api.github.com/users/JWGmeligMeyling/received_events","type":"User","site_admin":false},"body":"Looking for a way to get the `stderr` and `stdout` streams from a running (attach) or stopped (logs) container as `InputStream`, I eventually came up with the following solution. I added a method `attach(outputstream, outputstream)` to `LogStream`, which then iterates over all incoming `LogMessages` and sends them to the correct stream. I'd like to hear your thoughts on this approach.\r\n\r\nThis can be used in the following ways:\r\n\r\n### Binding to System.err and System.out\r\n```java\r\ndockerClient\r\n  .logs(containerId, LogsParameter.FOLLOW, LogsParameter.STDERR, LogsParameter.STDOUT)\r\n  .attach(System.out, System.err);\r\n```\r\n\r\n### Binding to piped inputstreams\r\n```java\r\nfinal PipedInputStream stdout = new PipedInputStream();\r\nfinal PipedInputStream stderr = new PipedInputStream();\r\nfinal PipedOutputStream stdout_pipe = new PipedOutputStream(stdout);\r\nfinal PipedOutputStream stderr_pipe = new PipedOutputStream(stderr);\r\n\r\nexecutor.submit(new Callable<Void>() {\r\n\r\n  @Override\r\n  public Void call() throws Exception {\r\n    dockerClient\r\n      .logs(containerId, LogsParameter.FOLLOW, LogsParameter.STDERR, LogsParameter.STDOUT)\r\n      .attach(stdout_pipe, stderr_pipe);\r\n    return null;\r\n  }\r\n  \r\n});\r\n\r\ntry (Scanner sc_stdout = new Scanner(stdout);\r\n    Scanner sc_stderr = new Scanner(stderr)) {\r\n  assertThat(sc_stdout.next(), equalTo(\"stdout\"));\r\n  assertThat(sc_stderr.next(), equalTo(\"stderr\"));\r\n}\r\n```\r\n","created_at":"2014-12-19T17:24:00Z","updated_at":"2015-02-18T17:18:13Z","closed_at":"2015-02-18T17:18:13Z","merged_at":"2015-02-18T17:18:13Z","merge_commit_sha":"cba154f4b7e1831c33926705ea26fe0629b6118d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/spotify/docker-client/pulls/110/commits","review_comments_url":"https://api.github.com/repos/spotify/docker-client/pulls/110/comments","review_comment_url":"https://api.github.com/repos/spotify/docker-client/pulls/comments/{number}","comments_url":"https://api.github.com/repos/spotify/docker-client/issues/110/comments","statuses_url":"https://api.github.com/repos/spotify/docker-client/statuses/f69ab8aeda3b92ea9d42c2612b80a0c9a4f63c5d","head":{"label":"JWGmeligMeyling:attach-logstream","ref":"attach-logstream","sha":"f69ab8aeda3b92ea9d42c2612b80a0c9a4f63c5d","user":{"login":"JWGmeligMeyling","id":3469492,"avatar_url":"https://avatars.githubusercontent.com/u/3469492?v=3","gravatar_id":"","url":"https://api.github.com/users/JWGmeligMeyling","html_url":"https://github.com/JWGmeligMeyling","followers_url":"https://api.github.com/users/JWGmeligMeyling/followers","following_url":"https://api.github.com/users/JWGmeligMeyling/following{/other_user}","gists_url":"https://api.github.com/users/JWGmeligMeyling/gists{/gist_id}","starred_url":"https://api.github.com/users/JWGmeligMeyling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JWGmeligMeyling/subscriptions","organizations_url":"https://api.github.com/users/JWGmeligMeyling/orgs","repos_url":"https://api.github.com/users/JWGmeligMeyling/repos","events_url":"https://api.github.com/users/JWGmeligMeyling/events{/privacy}","received_events_url":"https://api.github.com/users/JWGmeligMeyling/received_events","type":"User","site_admin":false},"repo":{"id":27991097,"name":"docker-client","full_name":"JWGmeligMeyling/docker-client","owner":{"login":"JWGmeligMeyling","id":3469492,"avatar_url":"https://avatars.githubusercontent.com/u/3469492?v=3","gravatar_id":"","url":"https://api.github.com/users/JWGmeligMeyling","html_url":"https://github.com/JWGmeligMeyling","followers_url":"https://api.github.com/users/JWGmeligMeyling/followers","following_url":"https://api.github.com/users/JWGmeligMeyling/following{/other_user}","gists_url":"https://api.github.com/users/JWGmeligMeyling/gists{/gist_id}","starred_url":"https://api.github.com/users/JWGmeligMeyling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JWGmeligMeyling/subscriptions","organizations_url":"https://api.github.com/users/JWGmeligMeyling/orgs","repos_url":"https://api.github.com/users/JWGmeligMeyling/repos","events_url":"https://api.github.com/users/JWGmeligMeyling/events{/privacy}","received_events_url":"https://api.github.com/users/JWGmeligMeyling/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JWGmeligMeyling/docker-client","description":"A simple docker client for the JVM","fork":true,"url":"https://api.github.com/repos/JWGmeligMeyling/docker-client","forks_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/forks","keys_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/teams","hooks_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/hooks","issue_events_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/issues/events{/number}","events_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/events","assignees_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/assignees{/user}","branches_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/branches{/branch}","tags_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/tags","blobs_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/statuses/{sha}","languages_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/languages","stargazers_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/stargazers","contributors_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/contributors","subscribers_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/subscribers","subscription_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/subscription","commits_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/issues/comments/{number}","contents_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/contents/{+path}","compare_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/merges","archive_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/downloads","issues_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/issues{/number}","pulls_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/pulls{/number}","milestones_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/milestones{/number}","notifications_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/labels{/name}","releases_url":"https://api.github.com/repos/JWGmeligMeyling/docker-client/releases{/id}","created_at":"2014-12-14T10:39:56Z","updated_at":"2014-12-25T15:37:16Z","pushed_at":"2014-12-26T00:57:31Z","git_url":"git://github.com/JWGmeligMeyling/docker-client.git","ssh_url":"git@github.com:JWGmeligMeyling/docker-client.git","clone_url":"https://github.com/JWGmeligMeyling/docker-client.git","svn_url":"https://github.com/JWGmeligMeyling/docker-client","homepage":"","size":618,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"spotify:master","ref":"master","sha":"c53e91c7364a95e81c1adcb624c0a7a87792be00","user":{"login":"spotify","id":251374,"avatar_url":"https://avatars.githubusercontent.com/u/251374?v=3","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"repo":{"id":20484506,"name":"docker-client","full_name":"spotify/docker-client","owner":{"login":"spotify","id":251374,"avatar_url":"https://avatars.githubusercontent.com/u/251374?v=3","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spotify/docker-client","description":"A simple docker client for the JVM","fork":false,"url":"https://api.github.com/repos/spotify/docker-client","forks_url":"https://api.github.com/repos/spotify/docker-client/forks","keys_url":"https://api.github.com/repos/spotify/docker-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spotify/docker-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spotify/docker-client/teams","hooks_url":"https://api.github.com/repos/spotify/docker-client/hooks","issue_events_url":"https://api.github.com/repos/spotify/docker-client/issues/events{/number}","events_url":"https://api.github.com/repos/spotify/docker-client/events","assignees_url":"https://api.github.com/repos/spotify/docker-client/assignees{/user}","branches_url":"https://api.github.com/repos/spotify/docker-client/branches{/branch}","tags_url":"https://api.github.com/repos/spotify/docker-client/tags","blobs_url":"https://api.github.com/repos/spotify/docker-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spotify/docker-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spotify/docker-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/spotify/docker-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spotify/docker-client/statuses/{sha}","languages_url":"https://api.github.com/repos/spotify/docker-client/languages","stargazers_url":"https://api.github.com/repos/spotify/docker-client/stargazers","contributors_url":"https://api.github.com/repos/spotify/docker-client/contributors","subscribers_url":"https://api.github.com/repos/spotify/docker-client/subscribers","subscription_url":"https://api.github.com/repos/spotify/docker-client/subscription","commits_url":"https://api.github.com/repos/spotify/docker-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/spotify/docker-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/spotify/docker-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/spotify/docker-client/issues/comments/{number}","contents_url":"https://api.github.com/repos/spotify/docker-client/contents/{+path}","compare_url":"https://api.github.com/repos/spotify/docker-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spotify/docker-client/merges","archive_url":"https://api.github.com/repos/spotify/docker-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spotify/docker-client/downloads","issues_url":"https://api.github.com/repos/spotify/docker-client/issues{/number}","pulls_url":"https://api.github.com/repos/spotify/docker-client/pulls{/number}","milestones_url":"https://api.github.com/repos/spotify/docker-client/milestones{/number}","notifications_url":"https://api.github.com/repos/spotify/docker-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spotify/docker-client/labels{/name}","releases_url":"https://api.github.com/repos/spotify/docker-client/releases{/id}","created_at":"2014-06-04T13:22:10Z","updated_at":"2015-02-18T17:18:13Z","pushed_at":"2015-02-18T17:18:13Z","git_url":"git://github.com/spotify/docker-client.git","ssh_url":"git@github.com:spotify/docker-client.git","clone_url":"https://github.com/spotify/docker-client.git","svn_url":"https://github.com/spotify/docker-client","homepage":"","size":2218,"stargazers_count":76,"watchers_count":76,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":35,"mirror_url":null,"open_issues_count":10,"forks":35,"open_issues":10,"watchers":76,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spotify/docker-client/pulls/110"},"html":{"href":"https://github.com/spotify/docker-client/pull/110"},"issue":{"href":"https://api.github.com/repos/spotify/docker-client/issues/110"},"comments":{"href":"https://api.github.com/repos/spotify/docker-client/issues/110/comments"},"review_comments":{"href":"https://api.github.com/repos/spotify/docker-client/pulls/110/comments"},"review_comment":{"href":"https://api.github.com/repos/spotify/docker-client/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/spotify/docker-client/pulls/110/commits"},"statuses":{"href":"https://api.github.com/repos/spotify/docker-client/statuses/f69ab8aeda3b92ea9d42c2612b80a0c9a4f63c5d"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"rohansingh","id":615175,"avatar_url":"https://avatars.githubusercontent.com/u/615175?v=3","gravatar_id":"","url":"https://api.github.com/users/rohansingh","html_url":"https://github.com/rohansingh","followers_url":"https://api.github.com/users/rohansingh/followers","following_url":"https://api.github.com/users/rohansingh/following{/other_user}","gists_url":"https://api.github.com/users/rohansingh/gists{/gist_id}","starred_url":"https://api.github.com/users/rohansingh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rohansingh/subscriptions","organizations_url":"https://api.github.com/users/rohansingh/orgs","repos_url":"https://api.github.com/users/rohansingh/repos","events_url":"https://api.github.com/users/rohansingh/events{/privacy}","received_events_url":"https://api.github.com/users/rohansingh/received_events","type":"User","site_admin":false},"comments":2,"review_comments":0,"commits":1,"additions":83,"deletions":0,"changed_files":1}}