Skip to content
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

interactive sessions hang #69

Open
wallnerryan opened this issue Mar 16, 2015 · 5 comments
Open

interactive sessions hang #69

wallnerryan opened this issue Mar 16, 2015 · 5 comments

Comments

@wallnerryan
Copy link

Reproduce:
Start powerstrip on 0.0.0.0:2375

docker run -d --name powerstrip -v /var/run/docker.sock:/var/run/docker.sock \
        -p 0.0.0.0:2375:2375 -v /etc/socketplane/adapters.yml:/etc/powerstrip/adapters.yml \
        --net=host clusterhq/powerstrip:v0.0.1
  • Local
docker -H tcp://localhost:2375 run -it ubuntu:12.04 /bin/bash
root@6becb4492d90:/# **<hangs, ENTER, Ctrl-C, does nothing>**
  • Remote
docker -H tcp://<powerstrip-host-ip>:2375 run -it ubuntu:12.04 /bin/bash
root@46a1c1bafd58:/# **<hangs, ENTER, Ctrl-C, does nothing>**
  • via Swarm (talks to powerstrip remotely)
docker -H tcp://<swarm-ip>:2375 run -it ubuntu:12.04 /bin/bash
root@e00362676720 :/# **<hangs, ENTER, Ctrl-C, does nothing>**

In each case I need to kill the process on the client machine to recover from the freeze/hang.

If I access the docker daemon port using -H on these hosts, interactive sessions have no problem using the same commands.

@wallnerryan
Copy link
Author

Just noticed this may be fixed in v.0.0.2

(from README change log)

v0.0.2:

Add integration tests against real Docker for run, build and pull, fix various bugs exposed therein.
In particular, fix docker attach, streaming responses when there are no post-hooks, GET requests, skip pre-hooks with application/tar handling, stdin handling for attach.

@binocarlos
Copy link
Contributor

Hey, you are absolutely right that v0.0.2 will fix this. v0.0.2 is currently masquerading as the unix-socket branch here

I've just done a test of this with the following commands to confirm (taken roughly from the Readme but basically replicating your setup above) - note this is on an Ubuntu host:

configure docker

We must tell docker to listen to the /var/run/docker.real.sock unix socket - this is done (on Ubuntu) by editing the `/etc/default/docker file to be (in my case):

DOCKER_OPTS="-H unix:///var/run/docker.real.sock -s aufs"

create adapters.yml

cat > /home/vagrant/powerstrip-demo/adapters.yml <<EOF
version: 1
endpoints:
  "POST /*/containers/create":
    pre: [slowreq]
adapters:
  slowreq: http://slowreq/slowreq-adapter
EOF

start adapter

sudo DOCKER_HOST="unix:///var/run/docker.real.sock" \
 docker run -d --name powerstrip-slowreq \
   --expose 80 \
   clusterhq/powerstrip-slowreq:v0.0.1

start powerstrip

sudo DOCKER_HOST="unix:///var/run/docker.real.sock" \
docker run -d --name powerstrip \
   -v /var/run:/host-var-run \
   -v /home/vagrant/powerstrip-demo/adapters.yml:/etc/powerstrip/adapters.yml \
   --link powerstrip-slowreq:slowreq \
   clusterhq/powerstrip:unix-socket

run interactive container

sudo docker run -it ubuntu:12.04 /bin/bash

interactive session

root@3e959e243604:/# ls -la
total 76
drwxr-xr-x  33 root root 4096 Mar 17 11:09 .
drwxr-xr-x  33 root root 4096 Mar 17 11:09 ..
-rwxr-xr-x   1 root root    0 Mar 17 11:09 .dockerenv
-rwxr-xr-x   1 root root    0 Mar 17 11:09 .dockerinit
drwxr-xr-x   2 root root 4096 Feb 28 22:12 bin
drwxr-xr-x   2 root root 4096 Apr 19  2012 boot
drwxr-xr-x   5 root root  380 Mar 17 11:09 dev
drwxr-xr-x  44 root root 4096 Mar 17 11:09 etc
drwxr-xr-x   2 root root 4096 Apr 19  2012 home
drwxr-xr-x  11 root root 4096 Feb 28 22:12 lib
drwxr-xr-x   2 root root 4096 Feb 28 22:12 lib64
drwxr-xr-x   2 root root 4096 Feb 28 22:12 media
drwxr-xr-x   2 root root 4096 Apr 19  2012 mnt
drwxr-xr-x   2 root root 4096 Feb 28 22:12 opt
dr-xr-xr-x 120 root root    0 Mar 17 11:09 proc
drwx------   2 root root 4096 Feb 28 22:12 root
drwxr-xr-x   5 root root 4096 Feb 28 22:12 run
drwxr-xr-x   2 root root 4096 Mar 10 17:21 sbin
drwxr-xr-x   2 root root 4096 Mar  5  2012 selinux
drwxr-xr-x   2 root root 4096 Feb 28 22:12 srv
dr-xr-xr-x  13 root root    0 Mar 17 11:09 sys
drwxrwxrwt   2 root root 4096 Feb 28 22:12 tmp
drwxr-xr-x  11 root root 4096 Mar 10 17:21 usr
drwxr-xr-x  12 root root 4096 Mar 10 17:21 var
root@3e959e243604:/# exit
exit
vagrant@node1:~$

The main change is that we are now binding on the unix-socket and making docker itself listen to /var/run/docker.real.sock.

I'm currently addressing a review for the unix-socket branch and will release v0.0.2 and update this issue when done :-)

@wallnerryan
Copy link
Author

Your example works, however I would still like to be able to access powerstrip on port 2375, and when i add -p 2375:2375 or -p 0.0.0.0:2375:2375 I am still getting error.

Start Docker on real.sock (i start docker on 2379 because I have swarm talking to powerstrip) things like registrator are now listening to docker.real.sock

/usr/bin/docker -d --log-level="fatal" -H tcp://0.0.0.0:2379 -H unix:///var/run/docker.real.sock &

Start powerstrip with host-var-run and port 2375

DOCKER_HOST="unix:///var/run/docker.real.sock" docker \
        run -d --name powerstrip -v /var/run:/host-var-run \
        -p 0.0.0.0:2375:2375 -v /etc/socketplane/adapters.yml:/etc/powerstrip/adapters.yml \
        --net=host clusterhq/powerstrip:v0.0.2

Since powerstrip 0.0.2 grabs /host-var-run/docker.sock and therefore can listen to sudo docker <cmd> for pre and post hooks should it still be able to expose the 2375.

sudo docker -H tcp://localhost:2375 ps
FATA[0000] Cannot connect to the Docker daemon. Is 'docker -d' running on this host? 

But when inpect the port is mapped but it cannot talk to powerstrip. In v0.0.1 i was able to expose port 2375 so swarm to connect to it. Is this intended behavior?

sudo docker inspect powerstrip
...
      "NetworkMode": "host",
        "PidMode": "",
        "PortBindings": {
            "2375/tcp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "2375"
                }
            ]
        },

@lukemarsden
Copy link
Contributor

Referencing #56 here.

This will be resolved for 0.0.2 by recommending the use of socat in an example in the README.

@binocarlos
Copy link
Contributor

@wallnerryan So I've just pushed to the unix-socket branch (the candidate for v0.0.2)

I've added a clear note to the Readme about using socat in order to proxy TCP traffic to the unix socket.

This is how I've got the unix socket version of powerstrip working with swarm for example.

The trouble with listening on a TCP socket from inside the powerstrip container is that attaching blows up (as in it does not echo stdout of the container). Even running socat from inside a container has the same problem.

The updated Readme is here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants