Restarting postgres in docker environment

I'm having trouble restarting dockerized postgres database (I am using Core OS). The database is launched in a bash script using the command

# boot.sh sudo -i -u postgres /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf 

which is working. I have another script called by confd that runs when some keys change, etc. (This part is fine, the file is being called correctly) and should restart postgres (not restart, because some configuration changes require a restart). Here are the main options I tried that failed ...

 # restart.sh sudo -u postgres /usr/lib/postgresql/9.3/bin/pg_ctl --pgdata=/var/lib/postgresql/9.3/main restart 

systematically causes an error:

 %FATAL: lock file "postmaster.pid" already exists %HINT: Is another postmaster (PID 273) running in data directory "/var/lib/postgresql/9.3/main"? 

Moreover,

 # restart.sh rm /var/lib/postgresql/9.3/main/postmaster.pid sudo -i -u postgres /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf 

 rm /var/lib/postgresql/9.3/main/postmaster.pid /etc/init.d/postgresql start 

 /etc/init.d/postgresql restart 

and

 exec su postgres -c "/usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf" 

glitch

 ERROR exit status 1 

Any thought? Thank you in advance!

+5
source share
1 answer

For me, configuration change and execution

 $ docker restart <postgres_container> 

the host works fine.

+3
source

Source: https://habr.com/ru/post/1206894/


All Articles