Report this

What is the reason for this report?

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

Posted on January 5, 2020

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)



This textbox defaults to using Markdown to format your 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.

Hello,

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.