Docker-compose: close ports after SIGTERM

I’m using Docker and Docker Compose for my development environment.

When I switch between projects, I usually have quite some pain because I receive a PORT ALREADY IN USE error.

  • Cannot start some containers after restarting docker daemon
  • How can Services running in a Docker VM and running on localhost register at EUREKA dynamically?
  • Jenkins SCM Sync Configuration Plugin In Docker Won't Talk to Github
  • Can not deploy custom MFP docker image on IBM Bluemix
  • Is docker-machine required on linux?
  • SSH into a docker container from another container on a different host
  • If I do docker-compose up (which makes my rails server start), is Ctrl+C the correct way to terminate this container?

    Here’s my docker-compose.yml file:

      image: postgres
        - "5432"
      build: .
      command: bundle exec rails s -p 3000 -b ''
        - .:/myapp
        - "3000:3000"
        - db

    Sometimes, I simply have to delete ./tmp/pids/, but sometimes I have to kill -9 some process.

    Here’s for example what ps -edf | grep docker outputs:

    root       742     1  0 Jul18 ?        00:01:11 /usr/bin/docker -d -H fd://
    root     22341   742  0 Jul21 ?        00:00:00 docker-proxy -proto tcp -host-ip -host-port 32781 -container-ip -container-port 5432
    root     22510   742  0 Jul21 ?        00:00:00 docker-proxy -proto tcp -host-ip -host-port 3030 -container-ip -container-port 3030
    root     28766   742  0 Jul21 ?        00:00:00 docker-proxy -proto tcp -host-ip -host-port 32783 -container-ip -container-port 5432
    root     28886   742  0 Jul21 ?        00:00:00 docker-proxy -proto tcp -host-ip -host-port 3000 -container-ip -container-port 3000

    Am I doing something wrong?

  • Trouble connecting to a SQL Server Database through a JBoss 6 EAP docker container
  • MariaDB Error executing 'postInstallation'
  • how to create a docker image and update task definition in ecs with it using wercker
  • Volume mapping for jenkins in docker which has access to host docker
  • Installing cabot via vagrant or docker
  • docker network in bridge mode
  • One Solution collect form web for “Docker-compose: close ports after SIGTERM”

    I would launch the container as a background process with docker-compose up -d. Then later you can do a shutdown with docker-compose stop in a clean way.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.