1

All the tutorials point out to running postgres in the format of

docker run -d -p 5432 \
  -t <your username>/postgresql \
  /bin/su postgres -c '/usr/lib/postgresql/9.2/bin/postgres \
    -D /var/lib/postgresql/9.2/main \
    -c config_file=/etc/postgresql/9.2/main/postgresql.conf'

Why can't we in our Docker file have:

ENTRYPOINT ["/etc/init.d/postgresql-9.2", "start"]

And simply start the container by

docker run -d psql

Is that not the purpose of Entrypoint or am I missing something?

2 Answers 2

2

the difference is that the init script provided in /etc/init.d is not an entry point. Its purpose is quite different; to get the entry point started, in the background, and then report on the success or failure to the caller. that script causes a postgres process, usually indirectly via pg_ctl, to be started, detached from the controlling terminal.

for docker to work best, it needs to run the application directly, attached to the docker process. that way it can usefully and generically terminate it when the user asks for it, or quickly discover and respond to the process crashing.

Sign up to request clarification or add additional context in comments.

Comments

1

Exemplify that IfLoop said.

Using CMD into Dockerfiles:

USE postgres 
CMD ["/usr/lib/postgresql/9.2/bin/postgres", "-D", "/var/lib/postgresql/9.2/main", "-c", "config_file=/etc/postgresql/9.2/main/postgresql.conf"]

To run:

$docker run -d -p 5432:5432 psql

Watching PostgeSQL logs:

$docker logs -f POSTGRES_CONTAINER_ID

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.