Sometimes, when I do "docker-compose up -d", I forget the "-d" part. So it starts to show me starting logs and if I do Ctrl + C it just terminates all the process and shows me the closing logs.
I have several questions about this :
If I manage to detach the process with detach keys (Ctrl P Ctrl Q by default) is it the exact same result as if I had started docker-compose with -d ?
Now if detach keys don't work (impossible to input Ctrl Q) is it the same result to do "Ctrl-Z" bg compared to starting docker-compose with -d ?
By default, a Docker Compose starts the services in the foreground mode just like a docker run command. To run the Docker Compose in the background, a docker-compose up command should be started with the -d or --detach option.
Run Docker Compose in detached mode by passing the -d flag to docker-compose up . Use docker-compose ps to review what you have running.
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.
Step 4: Build and run your app with Compose From your project directory, start up your application by running docker compose up . Compose pulls a Redis image, builds an image for your code, and starts the services you defined.
docker-compose up
displays streaming logs. This is the main advantage over docker-compose up -d
.
If you ran docker-compose up -d
, it's never too late. You are still able to display those streaming logs:
docker-compose logs -f
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