Docker container exits immediately after running o

2019-08-13 22:39发布

问题:

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:

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

回答1:

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.