Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shortcut command for docker-compose build + down + up

I found myself doing these three operations over and over again when modifying running Docker containers:

  1. docker-compose build
  2. docker-compose down
  3. 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.

like image 506
luqo33 Avatar asked Nov 04 '16 18:11

luqo33


People also ask

What is Docker compose up command?

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.

Which command is used to actually build the docker image?

With Dockerfile written, you can build the image using the following command: $ docker build .

What does Ctrl C do in docker?

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.


1 Answers

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.

like image 145
programmerq Avatar answered Sep 19 '22 09:09

programmerq