How can I add the CA certificate of my postgres cluster to a docker container?

The docker image is dotnet core and the posgrsql cluster is managed by digital ocean, I already got the connection from my local machine (windows) but I don’t know how to do it from the container (linux)


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.


What you could do here is build a new image on top of your current image add add the certificate there, for example, your Dockerfile would look something like this:

FROM ```your_current_image:latest```

COPY ./server.crt /home/```your_user```/.postgresql/server.crt
RUN chown postgres /home/```your_user```/.postgresql/server.crt

Then run docker build . and redeploy your new image.

That way our certificate would be available inside your container in your user’s home directory.

Another way to do that would be to have the certificate available on your host, create a docker volume and mount the volume to your running container.

Hope that this helps! Regards, Bobby