Docker extension

I am trying to extend the official postgres docker image to install a custom python module so that I can use it with the plpython3 stored procedure.

Here is my dockerfile

FROM postgres:9.5 RUN apt-get update && apt-get install -y postgresql-plpython3-9.5 python3 ADD ./repsug/ /opt/smtnel/repsug/ WORKDIR /opt/smtnel/repsug/ RUN ["python3", "setup.py", "install"] WORKDIR / 

My question is: do I need to add the ENTRYPOINT and CMD commands to my Docker file? Or are they "inherited" from the base image?

The official readme.md file shows a Docker file that only changes the locale without ENTRYPOINT or CMD.

I also read in readme that I can expand the image by running custom sh and / or sql scripts. Should I use this function instead of creating my own image? The question in this case is how do I make sure that the scripts are run only once at the "installation time", and not every time? I mean, if the database is already created and full, I would not want to overwrite it.

Thanks Awer

+6
source share
1 answer

If you define a new ENTRYPOINT in your Docker file, it will override the inherited ENTRYPOINT. Therefore, in this case, Postgres will not be able to automatically initialize (unless you write the same ENTRYPOINT).

https://docs.docker.com/engine/reference/builder/#entrypoint

In addition, the official postgres image allows you to add .sql / .sh files to the /docker-entrypoint-initdb.d folder, so they can be executed after the database is initialized.

Finally, if you do not want Postgres to delete your data, you can mount the volume between the /var/lib/postgresql/data folder and the local folder in each docker run ... to save it.

+5
source

All Articles