I am using Postgres with repmgr, one of the small problems I am having is that sometimes repmgr will have to stop and start the Postgres service and that will just kill the container, I tried some of the solutions online in the Dokcerfile but none seems to work, is there something I can add in the docker-compose file to prevent docker from exiting immediately, I don't want to stay alive forever, but maybe couple minutes?
Preventing the Docker container from exiting when the main process dies
1.4k Views Asked by Ali4356 At
2
There are 2 best solutions below
0
acran
On
The way docker is designed it will start a new container by starting the command specified as entrypoint/command to it and when this process terminates docker will kill all remaining processes in that container and shut it down.
So to keep the container running while the Postgres process is restarted you need to have another command running as the root process in the container.
You can achieve this by writing a simple shell script as a wrapper which will only exit when no Postgres process is running anymore or by using a dedicated init tool such as supervisord.
Related Questions in POSTGRESQL
- Only the first SQL script gets executed inside Docker Postgres container
- Compare fields in two tables
- Hibernate ClobJdbcType bindings: what are the diferences?
- Postgres && statement Error in Mybatis Mapper?
- Can this query be optimized? (Choosing a random row to insert, that excludes previously inserted Rows)
- Connection terminated unexpectedly while performing multi row insert using pg-promise
- Processing multiple forms in nodejs and postgresql
- How to copy data from SQLite to postgreSQL?
- PGAdmin4 configured behind a reverse proxy but unable to connect to Postgresql server
- Updates to pgsodium encrypted values don't use specified key_id
- Connecting to Postgres running in a Docker container using psql
- Can't connect to local postgresql server from my docker container
- Django Arrayfield migration to cloud sql (Postgresql) not creating the column
- Get list of matching keywords for each post
- docker-compose can't reset postgresql database
Related Questions in DOCKER
- sqlplus myusername/mypassword@ORCL not working with Oracle on Docker
- Golang == Error: OCI runtime create failed: unable to start container process: exec: "./bin": stat ./bin: no such file or directory: unknown
- Only the first SQL script gets executed inside Docker Postgres container
- Retrieve the Dockerfile configuration from the Kubernetes and also change container Java parameter?
- Polars with Rust: Out of Memory Error when Processing Large Dataset in Docker Using Streaming
- Compiling eBPF program in Docker fails due to missing '__u64' type
- AttributeError: module 'numba' has no attribute 'generated_jit'
- Phoenix in a docker dev environment - generated code can't be saved from VSCode
- Docker on Multipass VMs: Connecting worker nodes to swarm results in rcp error
- Facing error in creating image of my react+vite project . Dockerfile error
- NextJS Docker build fails: fetch failed ECONNREFUSED
- Docker container unable to make HTTPS requests to external API
- Failed to connect to your instance after deploying mern app on aws ec2 instance when i try to access frontend
- Connecting to Postgres running in a Docker container using psql
- Can't connect to local postgresql server from my docker container
Related Questions in POSTGRES-9.6
- Spring boot running too slow for postgres 9.6
- Postgres parameterized query with INSERT ON CONFLICT and geometry not working in PHP
- Filtering by JSON type field with Postgres and SQLAlchemy
- Upgrading Postgres while migrating to AWS - SQLSTATE[08006] [7] authentication method 10 not supported
- SQL execution failed: operator does not exist: bigint >= timestamp without time zone
- How to CREATE FUNCTION IF NOT EXISTS?
- PostgreSQL 9.6 Cast text datetime to timetamptz different results
- Postgres split full name to 3 parts First Middle Last
- What is wrong with trying to create two instances of docker-compose.yml
- Why are exclusive lower bounds converted to inclusive?
- How to upgrade postgrsql version from 9.6.5 to 9.6.14 on Centos 7.4
- Postgres changing the query from index Only scan to bit map scan when data set increases
- postgres logging_collector sending to two directories simultaneously
- create simple delete function postgresql
- Preventing the Docker container from exiting when the main process dies
Related Questions in REPMGR
- Issue encountered while adding a script for REPMGR split-brain prevention
- What is use case where we can see the benefit out of having witness node in the PG cluster
- How to join a failed node(primary) as standby in #repmgr automatic Failover #Postgresql-15
- postgresql-ha "unable to connect to upstream node" randomly, causing pgpool "kind does not match between main(0) slot[0] (52)"
- Why can't repmgr attach my replica to the master?
- error: connection to server at "10.0.30.7", port 5432 failed: No route to host
- Issue with repmgr's reported version during PostgreSQL 12 switchover
- repmgr pg_rewind failed with could not fetch pg_control remote file
- Postgres Register Standby fails
- Repmgr and PostgreSQL data_directory permission problem
- bitnami/postgresql-repmgr docker containers not finding each other
- Why does my postgresql+repmgr+timescaledb container stop right after start up?
- Why repmgr showing WAL replay is paused on all standby node?
- Unable to attach with upstream node using node rejoin
- Error: (repmgr) server is in standby mode and cannot be registered as a primary
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Remember that docker-composer is mostly development thing. For production there are other ways, like kubernetes.
The only solution i know is to run our own .sh script as main process, which would have infinite loop with necessary checks in it.
This way you can control how to check - like
ps auxand grep what you need. and exit main process if you need to by doing logic.sh scrip would look something like:
make sure you replace
postgres_service_namewith real name of Postgres service on linux.Use that script as a startup script in docker compose or whatever you would use in prod.
if you really need 2 minutes before it is off - i would implement logic which would measure time after first time process is not there