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,638
  • 5
  • 27
  • 47
LucasPG
  • 423
  • 1
  • 6
  • 22
  • 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

2 Answers2

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,659
  • 21
  • 26
2

Postgres should conatain password environmental variable as below: -e POSTGRES_PASSWORD=postgres

Add also, pgadmin should have two environmental variables(email and passworld) as below: -e 'PGADMIN_DEFAULT_EMAIL=address@email.something' -e 'PGADMIN_DEFAULT_PASSWORD=postgresmaster'

This is the email address used when setting up the initial administrator account to login to pgAdmin. This variable is required and must be set at launch time.

If these details are not given postgres and pgadmin will go to exited state.

Anand Raja
  • 2,676
  • 1
  • 30
  • 35
dawciobiel
  • 1,511
  • 1
  • 10
  • 11