docker

zendevil.eth 2021-08-07T07:07:02.054300Z

it still gives role datomic doesn’t exit

lispyclouds 2021-08-07T07:17:37.055700Z

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.eth 2021-08-07T07:46:11.056400Z

I simply used the default postgres role in the transactor

zendevil.eth 2021-08-07T07:46:25.056800Z

ad now it gives database “datomic” does not exist

zendevil.eth 2021-08-07T07:47:42.057600Z

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

lispyclouds 2021-08-07T08:04:25.058800Z

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.eth 2021-08-07T14:21:02.059700Z

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

zendevil.eth 2021-08-07T14:21:22.060100Z

and the postgres-db.sql script creates that db

zendevil.eth 2021-08-07T02:52:41.037900Z

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.eth 2021-08-07T03:21:30.038700Z

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.eth 2021-08-07T03:22:53.039100Z

but on initdb in the postgres dockerfile:

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

zendevil.eth 2021-08-07T03:24:08.039700Z

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

lispyclouds 2021-08-07T05:59:43.045100Z

@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.eth 2021-08-07T06:30:13.046800Z

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.eth 2021-08-07T06:32:49.048Z

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.eth 2021-08-07T06:44:20.048500Z

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

zendevil.eth 2021-08-07T06:44:23.048600Z

zendevil.eth 2021-08-07T06:45:31.049200Z

running the transactor now gives:

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

lispyclouds 2021-08-07T06:49:59.051300Z

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.eth 2021-08-07T06:51:56.052Z

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

lispyclouds 2021-08-07T06:52:05.052200Z

thats what the user is

lispyclouds 2021-08-07T06:52:19.052500Z

set POSTGRES_USER to datomic

lispyclouds 2021-08-07T06:52:52.053Z

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

lispyclouds 2021-08-07T06:54:25.053600Z

something like

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