I found myself doing these three operations over and over again when modifying running Docker containers:
docker-compose build
docker-compose down
docker-compose up
Is there a command in docker-compose that would do exactly these three things?
Of course a simple workaround would be to write a short shell script to the above. However, I guess that a shortcut command for the above would be very useful not only for me.
The docker compose up command aggregates the output of each container (like docker compose logs --follow does). When the command exits, all containers are stopped. Running docker compose up --detach starts the containers in the background and leaves them running.
With Dockerfile written, you can build the image using the following command: $ docker build .
Starting with docker 0.6. 5, you can add -t to the docker run command, which will attach a pseudo-TTY. Then you can type Control-C to detach from the container without terminating it.
The closest I can think of is this command:
docker-compose up --build --force-recreate
In my opinion, wrapping docker-compose in a shell script isn't a bad approach, but shouldn't be necessary in the situation you are describing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With