This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-07
Channels
- # announcements (10)
- # babashka (11)
- # beginners (69)
- # calva (1)
- # cider (2)
- # clj-kondo (35)
- # cljdoc (48)
- # cljs-dev (3)
- # clojure (60)
- # clojurescript (10)
- # community-development (6)
- # cursive (4)
- # datahike (1)
- # datalog (33)
- # deps-new (2)
- # depstar (8)
- # docker (24)
- # fulcro (1)
- # graphql (4)
- # honeysql (5)
- # java (2)
- # leiningen (2)
- # missionary (3)
- # off-topic (104)
- # pedestal (8)
- # polylith (18)
- # portkey (3)
- # reagent (7)
- # reveal (1)
- # rewrite-clj (4)
- # shadow-cljs (19)
- # specter (3)
- # tools-deps (2)
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
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
but on initdb in the postgres dockerfile:
initdb: error: directory "/var/lib/postgresql/data" exists but is not empty
How to fix this, and what determines the 172.18.0.4 ip?
@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 🙂
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
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)
this one has the copy command in the correct position. Ignore the previous zip
running the transactor now gives:
java.util.concurrent.ExecutionException: org.postgresql.util.PSQLException: FATAL: role "datomic" does not exist
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
I think the easiest thing to do now is to figure out a way to create the datomic role
thats what the user is
set POSTGRES_USER to datomic
if you start the container with these env vars, its created for you
something like
docker run \
-e POSTGRES_PASSWORD=datomic \
-e POSTGRES_USER=datomic \
-e POSTGRES_DB=datomic \
postgres
it still gives role datomic doesn’t exit
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
I simply used the default postgres role in the transactor
ad now it gives database “datomic” does not exist
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 datomicim 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
The reason this isn’t working is because the scripts that I copy to docker-entrypoint-initdb.d aren’t running
and the postgres-db.sql script creates that db