How to fail loudly during docker-compose up -d?

Using docker-compose up -d, when one of my containers fails to start (i.e. the RUN command exits with an error code), it fails quietly – How can I make it fail loudly?

(Am I thinking about this the right way? My ultimate goal is using Docker for my development environment. I’d like to be able to spin up my environment and be informed of errors right away. I’d like to stay to Docker’s true path as much as possible, and am hesitant to depend on additional tools like screen/tmux)

  • Docker registry error response from daemon i/o timeout
  • How to run nginx with docker container?
  • starting docker container from python messes up terminal settings
  • How do I use the public swagger-generator docker image to generate a client?
  • Mixing cpu-shares and cpuset-cpus in Docker
  • Apache Kafka IO errors
  • How to debug java in maven plug with angular 2, tomee in docker
  • How to do gracefully shutdown on dotnet with docker?
  • Running apache on docker with Dockerfile in windows boot2docker
  • How can I use XDebug with a PHP upstream behind an nginx reverse proxy?
  • Configure fluentd to properly parse and ship java stacktrace,which is formatted using docker json-file logging driver,to elastic as single message
  • “source” an 'sh' file for persistent variables in Docker
  • 2 Solutions collect form web for “How to fail loudly during docker-compose up -d?”

    Since you are running it detached (-d), docker-compose only spawns the containers and exits, without monitoring for any issues. If you run the containers in the foreground with:

    docker-compose up --abort-on-container-exit

    That should give you a pretty clear error on any container problems. Otherwise, I’d recommend looking into some of the other more advanced schedulers that monitor the running containers to recover from failures (e.g. Universal Control Plane or Kubernetes).

    Update: If you want to script something outside of the docker-compose up -d, you can do a

    docker events -f "container=${compose_prefix}_" -f "event=die"

    and if anything gets output there, you had a container go down. There’s also docker-compose events | grep "container die".

    As shown in compose/cli/, docker-compose is supposed to fail on (Dockerfile) build:

    except BuildError as e:
            log.error("Service '%s' failed to build: %s" % (, e.reason))

    Since -d (Detached mode, which runs containers in the background) is incompatible with --abort-on-container-exit, a “docker way” would be to:

    • wrap the docker compose up -d in a script
    • add to that script a docker-compose logs), parsing for any error, and loudly exiting if any error message is found..
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.