Fork me on GitHub
#docker
<
2021-08-07
>
zendevil.eth02:08:41

That eliminates the error, but now I get:

java.util.concurrent.ExecutionException: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "172.18.0.4", user "datomic", database "datomic", SSL off

zendevil.eth03:08:30

I tried copying a custom pg_hba.conf using COPY:

1 host    all             all             127.0.0.1/32            trust
  2 host    all             all             172.18.0.4/16           trust

zendevil.eth03:08:53

but on initdb in the postgres dockerfile:

initdb: error: directory "/var/lib/postgresql/data" exists but is not empty

zendevil.eth03:08:08

How to fix this, and what determines the 172.18.0.4 ip?

lispyclouds05:08:43

@ps this is the ip assigned via the docker bridge network. when you use the container name as the host name, the docker network acts as the DNS by adding the entries to /etc/resolv.conf. hence we are able to look up by container name. I would highly recomend reading up on on docker networking as i think this would be helpful for a larger scale setup youre planning: https://docs.docker.com/network/ and https://kerneltalks.com/networking/how-docker-container-dns-works/ , applies to k8s and others too. this is quite a fundamental aspect of docker thats very important to know. For the postgres error i think something else has run and created the db and youre trying to run the init db again. if all of the docker code is available in somewhere, we could help better 🙂

zendevil.eth06:08:13

actually I think that the reason it’s erroring out is because initdb writes files to /var/lib/postgresql/data including generated pg_hba but since I already copy a custom pg_hba to that directory it gives the error

zendevil.eth06:08:49

Here are the docker files, the create_db script, the deps.edn the custom pg_hba and the sql-transactor-template (you must add your license key)

zendevil.eth06:08:20

this one has the copy command in the correct position. Ignore the previous zip

zendevil.eth06:08:31

running the transactor now gives:

java.util.concurrent.ExecutionException: org.postgresql.util.PSQLException: FATAL: role "datomic" does not exist

lispyclouds06:08:59

try starting the postgres container with the POSTGRES_PASSWORD, POSTGRES_USER, POSTGRES_DB set to the values you want. the env vars described in https://github.com/docker-library/docs/blob/master/postgres/README.md#environment-variables that should create the user and you should not need the custom hba conf to connect too as long as youre using these credentials and user

zendevil.eth06:08:56

I think the easiest thing to do now is to figure out a way to create the datomic role

lispyclouds06:08:05

thats what the user is

lispyclouds06:08:19

set POSTGRES_USER to datomic

lispyclouds06:08:52

if you start the container with these env vars, its created for you

lispyclouds06:08:25

something like

docker run \
	-e POSTGRES_PASSWORD=datomic \
	-e POSTGRES_USER=datomic \
	-e POSTGRES_DB=datomic \
	postgres

zendevil.eth07:08:02

it still gives role datomic doesn’t exit

lispyclouds07:08:37

this should work. make sure youre connecting to the right container. the command above will create a new container. id suggest kill all postgres containers and use the env vars in the container you were creating before with the name

zendevil.eth07:08:11

I simply used the default postgres role in the transactor

zendevil.eth07:08:25

ad now it gives database “datomic” does not exist

zendevil.eth07:08:42

In Dockerfile_postgres lines:

12 RUN cp bin/sql/postgres-db.sql /docker-entrypoint-initdb.d
 13 RUN cp bin/sql/postgres-table.sql /docker-entrypoint-initdb.d
 14 RUN cp bin/sql/postgres-user.sql /docker-entrypoint-initdb.d
 15 USER postgres
 16 RUN initdb
are for this purpose but it doesn’t seem to create the database datomic

lispyclouds08:08:25

im not very familiar with datomic, maybe you could try examples like https://github.com/alexanderkiel/datomic-free ? also you could try asking in #datomic for some recommended docker setup

zendevil.eth14:08:02

The reason this isn’t working is because the scripts that I copy to docker-entrypoint-initdb.d aren’t running

zendevil.eth14:08:22

and the postgres-db.sql script creates that db