Compose: Docker-compose up exiting with code 0

Created on 1 Sep 2016  路  18Comments  路  Source: docker/compose

expected behaviour

start container and expose container bash

actual behaviour

starts up the container then exits the container shutting down the container

software/ hardware specs

Virtual box 5.0.24
Docker 1.2.11
Docker-compose version 1.8.0
OSX Yosemite

issue description

I'm trying to run a container using docker-compose via docker-compose.yml files but the process seems to start up the container and exits with a code 0 when running the command docker-compose -f docker-compose.yml -f docker-compose-dev.yml up . I really need to run some bash commands and live the container up and running
here is my docker-compose.yml

services:
  ngcracealong-rsync:
    # command: ["watch","-n3","ls -la"]
    command: 'bash'
    # entrypoint: '/bin/bash'
    # entrypoint: "lein with-profile dev do start-dev"
    container_name: 'docker-clojurescript'
    environment:
      - TERM=xterm
      - COMPOSE_HTTP_TIMEOUT=200
      - DEBUG=true
    expose:
      - "3000"
      - "9000"
    image: rand/docker-clojurescript
    ports:
      - "3000:3000"
      - "9000:9000"
    working_dir: '/data'
    read_only: false
    privileged: true
    # tty: true
    # command: "/bin/bash ls -la"
version: '2'

in a docker-compose-dev.yml

services:
  ngcracealong-rsync:
    volumes:
      - ngcracealong-rsync-sync:/data:rw
version: '2'
volumes:
  ngcracealong-rsync-sync:
    external: true

trying to execute a command like '/bin/bash ls -l' leads to some erroneous errors like 'commands not found' I can only assume that the commands are running before volumes are setup

a --verbose output yields

compose.config.config.find: Using configuration files: ./docker-compose.yml,./docker-compose-dev.yml
docker.auth.auth.load_config: File doesn't exist
compose.cli.command.get_client: docker-compose version 1.8.0, build unknown
docker-py version: 1.9.0
CPython version: 2.7.10
OpenSSL version: OpenSSL 0.9.8zh 14 Jan 2016
compose.cli.command.get_client: Docker base_url: https://192.168.99.103:2376
compose.cli.command.get_client: Docker version: KernelVersion=4.4.17-boot2docker, Os=linux, BuildTime=2016-08-18T17:52:38.255390991+00:00, ApiVersion=1.24, Version=1.12.1, GitCommit=23cf638, Arch=amd64, GoVersion=go1.6.3
compose.cli.verbose_proxy.proxy_callable: docker info <- ()
compose.cli.verbose_proxy.proxy_callable: docker info -> {u'Architecture': u'x86_64',
u'BridgeNfIp6tables': True,
u'BridgeNfIptables': True,
u'CPUSet': True,
u'CPUShares': True,
u'CgroupDriver': u'cgroupfs',
u'ClusterAdvertise': u'',
u'ClusterStore': u'',
u'Containers': 4,
u'ContainersPaused': 0,
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_network <- (u'ngcracealongdocker_default')
compose.cli.verbose_proxy.proxy_callable: docker inspect_network -> {u'Containers': {},
u'Driver': u'bridge',
u'EnableIPv6': False,
u'IPAM': {u'Config': [{u'Gateway': u'172.18.0.1',
u'Subnet': u'172.18.0.0/16'}],
u'Driver': u'default',
u'Options': None},
u'Id': u'bce4ac5ee716ed4b0b2b184632fd2a83423b78120fe51b9788d9b59ca248d669',
u'Internal': False,
u'Labels': {},
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_volume <- ('ngcracealong-rsync-sync')
compose.cli.verbose_proxy.proxy_callable: docker inspect_volume -> {u'Driver': u'local',
u'Labels': None,
u'Mountpoint': u'/mnt/sda1/var/lib/docker/volumes/ngcracealong-rsync-sync/_data',
u'Name': u'ngcracealong-rsync-sync',
u'Scope': u'local'}
compose.volume.initialize: Volume ngcracealong-rsync-sync declared as external. No new volume will be created.
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=False, filters={u'label': [u'com.docker.compose.project=ngcracealongdocker', u'com.docker.compose.oneoff=False']})
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={u'label': [u'com.docker.compose.project=ngcracealongdocker', u'com.docker.compose.service=ngcracealong-rsync', u'com.docker.compose.oneoff=False']})
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- (u'dfbae0eb3e7589786a8d9bf71bbe8a01cc22088cc88a4d0fa2b06fbccb29742d')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {u'AppArmorProfile': u'',
u'Args': [u'with-profile', u'dev', u'do', u'start-dev'],
u'Config': {u'AttachStderr': False,
u'AttachStdin': False,
u'AttachStdout': False,
u'Cmd': None,
u'Domainname': u'',
u'Entrypoint': [u'lein',
u'with-profile',
u'dev',
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('rand/docker-clojurescript')
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {u'Architecture': u'amd64',
u'Author': u'Rand Fitzpatrick rand.[email protected]',
u'Comment': u'',
u'Config': {u'AttachStderr': False,
u'AttachStdin': False,
u'AttachStdout': False,
u'Cmd': [u'bash'],
u'Domainname': u'',
u'Entrypoint': None,
u'Env': [u'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
...
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={u'label': [u'com.docker.compose.project=ngcracealongdocker', u'com.docker.compose.service=ngcracealong-rsync', u'com.docker.compose.oneoff=False']})
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('rand/docker-clojurescript')
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {u'Architecture': u'amd64',
u'Author': u'Rand Fitzpatrick rand.[email protected]',
u'Comment': u'',
u'Config': {u'AttachStderr': False,
u'AttachStdin': False,
u'AttachStdout': False,
u'Cmd': [u'bash'],
u'Domainname': u'',
u'Entrypoint': None,
u'Env': [u'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- (u'dfbae0eb3e7589786a8d9bf71bbe8a01cc22088cc88a4d0fa2b06fbccb29742d')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {u'AppArmorProfile': u'',
u'Args': [u'with-profile', u'dev', u'do', u'start-dev'],
u'Config': {u'AttachStderr': False,
u'AttachStdin': False,
u'AttachStdout': False,
u'Cmd': None,
u'Domainname': u'',
u'Entrypoint': [u'lein',
u'with-profile',
u'dev',
...
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Starting producer thread for
compose.service.start_container_if_stopped: Starting docker-clojurescript
compose.cli.verbose_proxy.proxy_callable: docker attach <- (u'dfbae0eb3e7589786a8d9bf71bbe8a01cc22088cc88a4d0fa2b06fbccb29742d', stream=True, stderr=True, stdout=True)
compose.cli.verbose_proxy.proxy_callable: docker attach ->
compose.cli.verbose_proxy.proxy_callable: docker start <- (u'dfbae0eb3e7589786a8d9bf71bbe8a01cc22088cc88a4d0fa2b06fbccb29742d')
compose.parallel.feed_queue: Pending: set([])
compose.cli.verbose_proxy.proxy_callable: docker start -> None
compose.parallel.parallel_execute_iter: Finished processing:
compose.parallel.feed_queue: Pending: set([])
Attaching to docker-clojurescript
compose.cli.verbose_proxy.proxy_callable: docker events <- (decode=True, filters={u'label': [u'com.docker.compose.project=ngcracealongdocker', u'com.docker.compose.oneoff=False']})
compose.cli.verbose_proxy.proxy_callable: docker events ->
docker-clojurescript | 'start-dev' is not a task. See 'lein help'.
docker-clojurescript | Error encountered performing task 'do' with profile(s): 'dev'
docker-clojurescript | Task not found
compose.cli.verbose_proxy.proxy_callable: docker wait <- (u'dfbae0eb3e7589786a8d9bf71bbe8a01cc22088cc88a4d0fa2b06fbccb29742d')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- (u'dfbae0eb3e7589786a8d9bf71bbe8a01cc22088cc88a4d0fa2b06fbccb29742d')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {u'AppArmorProfile': u'',
u'Args': [u'with-profile', u'dev', u'do', u'start-dev'],
u'Config': {u'AttachStderr': False,
u'AttachStdin': False,
u'AttachStdout': False,
u'Cmd': None,
u'Domainname': u'',
u'Entrypoint': [u'lein',
u'with-profile',
u'dev',

Can someone help me figure ut what is going wrong here?

Most helpful comment

tty: true doesn't work for me

All 18 comments

I would uncomment tty: true, and run COMPOSE_HTTP_TIMEOUT=8000 ocker-compose -f docker-compose.yml -f docker-compose-dev.yml up

@shin- read on another issue that this was removed from the spec.....is this option still available? users had issues using it as it caused the containers to hang

tty? It has not been removed from the spec. There's an issue with HTTP timeouts, as pointed out in #3633, which is why I suggested to work around it using COMPOSE_HTTP_TIMEOUT=8000 (or more if you need a longer session).

@shin- well I tried your solution and no dice. Must say this has been a frustrating week debugging this docker tooling framework rather than working on my own project ....sigh

I'm sorry to hear you're having a frustrating experience :( Do you mind clarifying what the issue you're running into is?

simple. I'm using docker-sync framework to start and sync a container and access its shell to run some commands but as stated in the issue....it seems to "exit" upon creation not sure why it is doing this.

I must admit I am not familiar with how docker-sync works, but I was able to run a long-lived container using the following config:

docker-compose.yml

services:
  ngcracealong-rsync:
    entrypoint: ['bash']
    container_name: 'docker-clojurescript'
    environment:
      - DEBUG=true
    expose:
      - "3000"
      - "9000"
    image: rand/docker-clojurescript
    ports:
      - "3000:3000"
      - "9000:9000"
    working_dir: '/data'
    read_only: false
    privileged: true
    tty: true
version: '2'

docker-compose-dev.yml

services:
  ngcracealong-rsync:
    volumes:
      - ngcracealong-rsync-sync:/data:rw
version: '2'
volumes:
  ngcracealong-rsync-sync:
    external: true

And running docker-compose -f docker-compose.yml -f docker-compose-dev.yml up seems to start properly. Do you see any significant difference with your current setup that could account for the differences?

other than I'm running on an external drive and trying to mount a volume from my host file system no..... I'm not familiar with docker-compose but if i were to use docker run everything would work as expected. So I'm not sure why docker compose is acting this way....I'm using docker-sync because their process seems to speed things up with respect to syncing files in developing on the fly....

From the looks of things thought Vagrant is looking pretty awesome right about now

tty: true was key :)

i have the same problem

@zuernBernhard tty:true hangs

@karneaud I already use it. The problem is that I use vagrant with docker. When docker use volume and vagrant use share folder then the container stops immediately.

tty: true doesn't work for me

I have the same issue: here is my docker-compoe file:

version: '3'

services:
    xdev:
      build:
        context: .
        dockerfile: ./docker/development/Dockerfile
      container_name: xdev
      expose:
        - "80"
        - "443"
      ports:
        - "80:80"
        - "443:443"
      tty: true
      volumes:
        - .:/var/www/html
      #depends_on:
      #  - oracledb

    oracledb:
      image: wnameless/oracle-xe-11g
      expose:
        - "1521"
      ports:
        - "1521:1521"

$docker-compose up
Recreating xdev ...
Recreating xdev ... done
Attaching to xdev_oracledb_1, xdev
xdev | => Xdebug is already configured
xdev | => Starting Apache ...
oracledb_1 | Starting Oracle Net Listener.
oracledb_1 | Starting Oracle Database 11g Express Edition instance.
oracledb_1 |
oracledb_1 | /usr/sbin/startup.sh: ignoring /docker-entrypoint-initdb.d/*
oracledb_1 |
oracledb_1 | Starting Oracle Net Listener.
oracledb_1 | Starting Oracle Database 11g Express Edition instance.
oracledb_1 |
oracledb_1 | /usr/sbin/startup.sh: ignoring /docker-entrypoint-initdb.d/*
oracledb_1 |
xdev exited with code 0

I have the same issue but then found the error.
I was writing some wrong command in Docker file.

So need to investigate the issue you need to comment your commands and check with rebuild. It will show you the issue.

I have the same issue and tty: true doesn't work for me.
the log as follows:
Starting scene-graph-master_web_1 ... done
Recreating scene-graph-master_scene_graph_1 ... done
Starting scene-graph-master_detectron_1 ... done
Attaching to scene-graph-master_detectron_1, scene-graph-master_web_1, scene-graph-master_scene_graph_1
scene-graph-master_detectron_1 exited with code 0

who can help me ?very thanks

in the docker-compose.yml file add the below code in services
stdin_open: true

I would uncomment tty: true, and run COMPOSE_HTTP_TIMEOUT=8000 ocker-compose -f docker-compose.yml -f docker-compose-dev.yml up

yeah tty: true worked for me, what's the reasoning behind this?

Was this page helpful?
0 / 5 - 0 ratings