2

I am begginer with docker, and I stuck in place due to container restarting problem. The problem occures when I try to restart an existing exited container, or create new container (after deleting old one) running:

docker run -d --name mempostgres \
    -v "/home/lukasz/lc_pg_data:/var/lib/pgsql/data:Z" \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_PASSWORD=password \
    -e POSTGRES_DB=dbName \
    -p 5432:5432 \
    fedora/postgresql

My container always exits immediately with status "Exited(1)"

Inside the logs of my container i have: enter image description here

However I don't have any PostgreSQL server running at this moment.

Massimiliano Kraus
  • 3,433
  • 5
  • 24
  • 45
LucasPG
  • 429
  • 1
  • 5
  • 20
  • Not an answer but the image isn't really up to date. I would recommend to use the official postgres image: https://hub.docker.com/_/postgres/ – lvthillo Jun 12 '17 at 10:55
  • If you are sure that there is no another Postgres running, delete that .pid file. – Robert Jun 12 '17 at 11:35
  • For me deleting the files helped. Well I didn't have any database or anything. it happened to me by initializing the pg – Amir Jun 18 '21 at 16:39

1 Answers1

2

You need to kill that postmaster process.

cat .../postmaster.pid

The first number of this file is the PID of postmaster process.

Then, kill that process using:

kill PID

Finally, run a container, your problem should be fixed.

kstromeiraos
  • 4,221
  • 20
  • 25