Development workflow for docker-compose: run a dev-version container

I have a quite typical docker-compose setup: a custom web container and a database container directly from docker hub. For development, my host directory is mounted into the web docker so that I do not have to rebuild container each time I do a minor change. The web server is a Passenger (standalone) serving a ruby app.

When I run it, I have my database running, my web service running (on port 3000), all good. However, if I do a change, nothing changes as the web server (passenger) needs to be relaunched. I would like to have to be able to launch a simple lightweight development server such as thin that I would restart manually when I do a change.

  • Application logging .net core & docker
  • How to run a web-project's branches in parallel?
  • LXC integration and auto-scaling with Mesos
  • Dockerfile COPY {source-…}
  • Unable to find Kubernetes apiserver's data in etcd3
  • Kubernetes PullImageError using Docker Hub with a private image
  • What I tried:

    • Launching a new web container (docker-compose run web ...) does not expose any port for the new container. So, I cannot connect to the web server.
    • Launching a new web container with Docker directly (docker run web -p 5000:5000 image_name ...). We loose the docker-compose functionality, the container is not linked to the database without manual bindings.
    • Relaunching the docker-compose each time (as it starts quickly). Each time my database is relaunched so empty, I need to keep running.
    • Use --service-ports arg: do not work as port 3000 is already used
    • docker exec my dev server on the web container: has to run on another port, so will not be exposed.
    • docker exec the kill of my webserver: actually it works (it restarts), but I do not really like this solution. Firstly, because the server is still Passenger where I would prefer a lightweight web server (as thin). Secondly, I find it not very clean to connect to kill over and over the server with docker exec ....
    • Changing my Dockerfile to replace Passenger by an auto-relaunching dev web server: I like the Dockerfile to be the same as on the prod server, tests, and dev.

    Would you have a clean and easy way of just launching my web container, with port 5000 open, on which I would a shell the launch/relaunch a dev web server ?

  • docker: Dockerising multiple wordpress sites
  • Docker swarm mode couldnt connect to another container
  • How can I copy a Docker container's configuration when I commit an image?
  • Should Swarm Master Join As Node in a Single Node Cluster?
  • Can I export a container with data and everything to spawn a complete copy on another computer?
  • docker build inside official jenkins container
  • One Solution collect form web for “Development workflow for docker-compose: run a dev-version container”

    I use two docker-compose files, one for development and one for production.

    In development the docker-compose file you can override the CMD from your Dockerfile with command so you can easily use bash to have a shell or use an auto relaunch server.

    To use you custom docker-compose file do : docker-compose -f dev.yml ...

    And for this :

    Relaunching the docker-compose each time (as it starts quickly). Each time my database is relaunched so empty, I need to keep running.

    If you do docker-compose up --no-deps web it will not relaunch your db

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