Docker compose hangs at "Attaching to"

I have this yml file that I use with docker compose but the command hangs.

es:
 image: local/repo:elastic_search
 ports:
  - "9200:9200"
  - "9300:9300"
 volumes:
  - /var/log/elasticsearch:/var/log/elasticsearch
db:
 image: local/repo:mongodb
 ports:
  - "27017:27017"
  - "27018:27018"
 volumes:
  - /var/log/mongodb:/var/log/mongodb
app:
 image: local/repo:tomcat7
 ports:
  - "443:443"
  - "8998:8998"
  - "8999:8999"
 links:
  - es:es
  - db:db
 volumes:
  - /opt/repo/deploy:/opt/repo/deploy
  - /opt/repoadmin/deploy:/opt/repoadmin/deploy
  - /var/log/tomcat7:/var/log/tomcat7

The verbose output is given below:

$ docker-compose --verbose -f docker-compose-test.yml up
Compose version 1.3.3
Docker base_url: http+docker=>localunixsocket
Docker version: KernelVersion=3.13.0-57-generic, Os=linux, ApiVersion=1.19, Version=1.7.1, GitCommit=786b29d, Arch=amd64, GoVersion=go1.4.2
docker containers <- (all=True, filters={u’label’: [u’com.docker.compose.project=dockerrepo’, u’com.docker.compose.service=db’, u’com.docker.compose.oneoff=False’]})
docker containers -> (list with 1 items)
docker inspect_container <- (u’600df117e6963db0f140b820c2009194796541871122a5b0d7acffdd1614661b’)
docker inspect_container -> {u’AppArmorProfile’: u’’,
u’Args’: [],
u’Config’: {u’AttachStderr’: False,
u’AttachStdin’: False,
u’AttachStdout’: False,
u’Cmd’: None,
u’CpuShares’: 0,
u’Cpuset’: u’’,
u’Domainname’: u’’,
u’Entrypoint’: [u’/bin/bash’],
…

…
docker start <- (u’1111e051efa15e1a49f426f1bcaf706847b0cfc360d672cae80413ac95d7acca’)
docker start -> None
docker remove_container <- (u’6fee9a6f10b50e4aae983b8831f046430571eeccbc13699b4f82f4caf6aa92ca’)
docker remove_container -> None
docker containers <- (all=False, filters={u’label’: [u’com.docker.compose.project=dockerrepo’, u’com.docker.compose.service=db’, u’com.docker.compose.oneoff=False’]})
docker containers -> (list with 0 items)
docker containers <- (all=True)
docker containers -> (list with 6 items)
docker containers <- (all=False, filters={u’label’: [u’com.docker.compose.project=dockerrepo’, u’com.docker.compose.service=es’, u’com.docker.compose.oneoff=False’]})
docker containers -> (list with 0 items)
docker containers <- (all=True)
docker containers -> (list with 6 items)
docker containers <- (all=False, filters={u’label’: [u’com.docker.compose.project=dockerrepo’, u’com.docker.compose.service=app’, u’com.docker.compose.oneoff=False’]})
docker containers -> (list with 0 items)
docker containers <- (all=True)
docker containers -> (list with 6 items)
Attaching to

And this is where it hangs at attaching to. Weird that it doesn’t even say what is it trying to attach to. Note that starting the containers with docker and same volumes and links works just fine. Any ideas?

I couldn’t work out how to paste the whole output due some two links limitation for new users but can provide it if needed.

Thanks,
Igor

Have you got docker 1.7+ ? If not then try it out. I’d got the same problem until docker-compose and docker update

This are my versions:

$ docker-compose -v
docker-compose version: 1.3.3
CPython version: 2.7.6
OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014

$ docker -v
Docker version 1.7.1, build 786b29d

When I run with “-d” option this is what compose shows me:

$ docker-compose ps
Name             Command    State                                          Ports                                         
--------------------------------------------------------------------------------------------------------------------------------
dockerlocal_app_1   /bin/bash   Up      22/tcp, 0.0.0.0:443->443/tcp, 80/tcp, 0.0.0.0:8998->8998/tcp, 0.0.0.0:8999->8999/tcp 
dockerlocal_db_1    /bin/bash   Up      22/tcp, 0.0.0.0:27017->27017/tcp, 0.0.0.0:27018->27018/tcp, 28017/tcp, 28018/tcp     
dockerlocal_es_1    /bin/bash   Up      22/tcp, 0.0.0.0:9200->9200/tcp, 9300/tcp                                             

However in docker I can see why the attach is not working:

$ docker ps
CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS                          PORTS                                                                    NAMES
9f7db4f7ccda        dockerlocal_app   "/bin/bash"         30 hours ago        Restarting (0) 30 minutes ago   22/tcp, 0.0.0.0:443->443/tcp, 80/tcp, 0.0.0.0:8998-8999->8998-8999/tcp   dockerlocal_app_1   
8711bc2f456f        dockerlocal_es    "/bin/bash"         30 hours ago        Restarting (0) 30 minutes ago   22/tcp, 9300/tcp, 0.0.0.0:9200->9200/tcp                                 dockerlocal_es_1    
28017aa53b26        dockerlocal_db    "/bin/bash"         30 hours ago        Restarting (0) 30 minutes ago   22/tcp, 28017-28018/tcp, 0.0.0.0:27017-27018->27017-27018/tcp            dockerlocal_db_1

The containers are in permanent restart loop thus attach blocks.

Thanks,
Igor

I had the same issue with my mongo container. I think there should be different state of container displayed instead of up to avoid confusion.

Well as I said before the containers when created via docker using the same images and same launch configuration run fine. Why are they restarting with docker-compose?

I’m seeing the same problem, it’s like stdout is deadlocked on my web container. Docker 1.8.2 and Compose 1.4.1. This is only hanging on ubuntu, not on OSX. Did you figure out the problem?

I have the same problem on MacOSX with docker toolbox 1.8.2a (compose 1.4.1). This problem did not occur with any version of toolbox between 1.8.1d and 1.8.2. Hope that helps narrow it down…

@rosskevin and @jxstanford, it looks like this is a regression that showed up in 1.4.1, but has been fixed in 1.4.2 (I’ve verified that upgrading fixes the problem on my Ubuntu machine).

+1 thank you, 1.4.2 fixed my attach problem.

That’s good news. I’ll check it out in the next version of toolbox.

Best regards,

John
@jxstanford

As a quick work around I have found that adding the --verbose flag seems to get you into the terminal. Not exactly sure why:
ex: docker exec -it container:id bash --verbose

I put these lines to docker-compose.yml. It works fine.

command: /bin/bash
tty: true
stdin_open: true

or “docker exec -it (container name/id) /bin/bash” for attaching after up with -d. Also work fine.

2 Likes