# PostgreSQL database server running locally in a Renku docker container

**URL:** https://renku.discourse.group/t/postgresql-database-server-running-locally-in-a-renku-docker-container/739
**Category:** General
**Created:** [11 January 2023 10:46 UTC](https://renku.discourse.group/t/postgresql-database-server-running-locally-in-a-renku-docker-container/739 "2023-01-11T10:46:46Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![champost](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/champost/32/232_2.png) [@champost](https://renku.discourse.group/u/champost)
#### Post date: [11 January 2023 10:46 UTC](https://renku.discourse.group/t/postgresql-database-server-running-locally-in-a-renku-docker-container/739/1 "2023-01-11T10:46:46Z")

</div>

Hello,

On the Renku [Best Practices](https://renkulab.io/gitlab/best-practices/connect-to-sql) Gitlab group, it is shown how to connect to a remote PostgreSQL database server, which is useful.

- Would it be possible to have a PostgreSQL database server running locally in a Renku docker container ?
- If yes, what would be the best way to implement this in a Renku project ?

Thanks !

---

<div class="post-metadata">

### Author: ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)
#### Post date: [19 January 2023 08:55 UTC](https://renku.discourse.group/t/postgresql-database-server-running-locally-in-a-renku-docker-container/739/2 "2023-01-19T08:55:52Z")

</div>

Hi @champost - do you need a full postgres server or would something simpler like sqlite be sufficient given that it’s just running locally? In any case, you could certainly install a server and run it inside the container if you wanted. You would need to install it in the image and then start it, either in the image directly or via a `post-init.sh` script (which runs after the session starts so it has all the local state if you need it for e.g. environment variables).

---

<div class="post-metadata">

### Author: ![champost](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/champost/32/232_2.png) [@champost](https://renku.discourse.group/u/champost)
#### Post date: [20 January 2023 11:12 UTC](https://renku.discourse.group/t/postgresql-database-server-running-locally-in-a-renku-docker-container/739/3 "2023-01-20T11:12:31Z")

</div>

Hi @rrrrrok,

Thanks for the input.

[`sqlite`](https://www.sqlite.org/index.html) does seem be a good option for our use-case and the `sqlite3` python package seems to be available “out of the box” in Renku !

---

<div class="post-metadata">

### Author: ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)
#### Post date: [20 January 2023 15:22 UTC](https://renku.discourse.group/t/postgresql-database-server-running-locally-in-a-renku-docker-container/739/4 "2023-01-20T15:22:13Z")

</div>

great, let me know how it goes!

---

<div class="post-metadata">

### Author: ![champost](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/champost/32/232_2.png) [@champost](https://renku.discourse.group/u/champost)
#### Post date: [24 February 2023 15:41 UTC](https://renku.discourse.group/t/postgresql-database-server-running-locally-in-a-renku-docker-container/739/5 "2023-02-24T15:41:50Z")

</div>

Hello @rrrrrok ,

Finally it is a full PostgresSQL server that I would be needing for a Renku project.

> In any case, you could certainly install a server and run it inside the container if you wanted. You would need to install it in the image and then start it, either in the image directly or via a `post-init.sh` script (which runs after the session starts so it has all the local state if you need it for e.g. environment variables).

I tried but I would prefer if you are able to show me how to correctly setup a running PostgreSQL server within a (Renku) Docker container ?

Thanks !

---

<div class="post-metadata">

### Author: ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)
#### Post date: [24 February 2023 16:14 UTC](https://renku.discourse.group/t/postgresql-database-server-running-locally-in-a-renku-docker-container/739/6 "2023-02-24T16:14:52Z")

</div>

Hi @champost, can you show me a project where you’ve tried this already?

---

<div class="post-metadata">

### Author: ![champost](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/champost/32/232_2.png) [@champost](https://renku.discourse.group/u/champost)
#### Post date: [24 February 2023 16:39 UTC](https://renku.discourse.group/t/postgresql-database-server-running-locally-in-a-renku-docker-container/739/7 "2023-02-24T16:39:51Z")

</div>

Hi @rrrrrok

I had started working on a new branch in a private Renku project of a research group that I am helping out with such tasks.

In it, I basically installed postgresql and postgresql-contrib via apt-get in the Dockerfile. I haven’t yet managed to figure out how to fire up the DB server as you suggested via the Dockerfile or via post-init.sh

Should I create a new test project to share and invite you and we go on from there ?

---

<div class="post-metadata">

### Author: ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)
#### Post date: [24 February 2023 16:40 UTC](https://renku.discourse.group/t/postgresql-database-server-running-locally-in-a-renku-docker-container/739/8 "2023-02-24T16:40:48Z")

</div>

yes please, that would be great!

---

<div class="post-metadata">

### Author: ![champost](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/champost/32/232_2.png) [@champost](https://renku.discourse.group/u/champost)
#### Post date: [24 February 2023 17:19 UTC](https://renku.discourse.group/t/postgresql-database-server-running-locally-in-a-renku-docker-container/739/9 "2023-02-24T17:19:47Z")

</div>

Here is the link to the project : [Champak Beeravolu Reddy / postgresql server in renku · GitLab](https://renkulab.io/gitlab/champak.beeravolureddy/postgresql-server-in-renku)

I was trying to setup `postgresql` on Ubuntu 22.04 ([How To Install PostgreSQL on Ubuntu 22.04 [Quickstart] | DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-install-postgresql-on-ubuntu-22-04-quickstart)) and create a database which the default local user in Renku should be able to access via the `psycopg` package (as in [notebooks/psycopg-example.ipynb · master · Best Practices / connect-to-sql · GitLab](https://renkulab.io/gitlab/best-practices/connect-to-sql/-/blob/master/notebooks/psycopg-example.ipynb)). In my case, the local user would thus open a connection on the localhost.

I have also added your username rok.roskar as a maintainer to the project.
