I have mongodb container that already run, someday the container is suddenly down, my mistake is not take a look in the container logs and not start the container but delete it and rebuild new container. But this ever happen the container down just after running mongodump, does mongodump can make mongodb container down or its something else?
Iām not sure I understand the lasts entence. Can you rephrase it?
The container doesnāt exist without the process. Stopping the container means stopping the process in it. So if you are wondering whether a crashed mongodb also means the container will stop, yes. At least if the mongodb is the main process that keeps the container alive.
somehow the container is down, to make it up again it just need to start the container right? but instead of doing that, what Iām done is delete the stoped container and build new one, so that way I cant see the docker logs because its already deleted. then my question is, can I know what makes the container down without looking to docker container logs?
yes
Depends on the logging driver, but the default is json, which is deleted when the container is deleted.
Here are the supported logging drivers:
https://docs.docker.com/config/containers/logging/configure/#supported-logging-drivers
For example the journald driver on Linux allows you to send the logs to the journa logs of the host. That stays available when you delete the container, but journald is not supported in Docker Desktop. If you use linux, that could be an option. Otherwise, you can send the logs to a remote server.
since Iām not set up logging so its impossible to know why container is down because the container already deleted? but, is it possible that mongodump process make the container down? thank you for your help
Is the container really removed? Or has it just died?
Use docker ls -a
to see all containers, running and killed (but not removed).
I believe I answered it in my previous post, but once again, if the main process stops in the container, the container stops. Is it possible that the process stopped in the container? Of course. Why it stopped? Only the god of logs can tell you. Or the logs directly.
You could also try journalctl -e -u docker
Or see the full journal logs: journalctl -e
at the time when the container stopped. You wonāt see the container logs there, but you can find if there was a memory issue and the host killed mongodb.
@bluepuma77 meant docker ps -a
, which shows stopped containers. I donāt think that is the problem since you wrote