smad
smad

Reputation: 1120

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.

What I tried:

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 ?

Upvotes: 3

Views: 355

Answers (1)

Uhsac
Uhsac

Reputation: 819

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

Upvotes: 3

Related Questions