This Dockerfile packages planter and plantuml into a Docker image. They are both needed to get Postgres ER diagrams as images.
Create an ER diagram out of the whole Postgres database from the default public
schema tables:
alias plant='docker run -v $PWD:/root -w /root --rm -it kimmobrunfeldt/planter'
# or replace `docker` with `podman`
plant er postgres://planter@localhost/planter?sslmode=disable
or from data
schema, from tables matching table_name LIKE '%user%'
:
plant er postgres://planter@localhost/planter?sslmode=disable data "LIKE '%user%'"
or using POSIX regex that matches tables containing user
or profile
:
plant er postgres://planter@localhost/planter?sslmode=disable public "~ '(user|profile)'"
or create an ER diagram of all tables with the original CLI tools:
plant planter postgres://planter@localhost/planter?sslmode=disable -o example.uml
plant plantuml -verbose example.uml
In Fedora, if you're using podman, you need to add option --security-opt label=disable
for the run command to disable SELinux security isolation which prevents volume mounting. See containers/podman#3683 for more.
The created diagram is empty!
Make sure the postgres schema is correct. The default is public
.
docker run -v $PWD:/root -w /root --rm -it kimmobrunfeldt/planter <command> <args>
The Docker file exposes these commands:
planter <args>
Which would be same as runningplanter <args
(surprise). Arguments are directly passed to planter.plantuml <args>
Which would be same as runningjava -jar plantuml.jar <args>
.er <postgres-url> [postgres-schema] [tables-name-matcher] [output-file-name]
Which is a convenience command for combining commands and directly getting the image.
docker pull kimmobrunfeldt/planter:latest
podman build --cgroup-manager=cgroupfs .
Then use the podman run
command but replace kimmobrunfeldt/planter
with the
image id returned by build.
Without the extra flag, building fails to:
STEP 1: FROM ubuntu:18.04
STEP 2: RUN apt-get -q -y update
ERRO[0000] systemd cgroup flag passed, but systemd support for managing cgroups is not available
systemd cgroup flag passed, but systemd support for managing cgroups is not available
error running container: error creating container for [/bin/sh -c apt-get -q -y update]: : exit status 1
Error: error building at STEP "RUN apt-get -q -y update": error while running runtime: exit status 1
More at opencontainers/runc#2163.
This project is a grateful recipient of the Aiven Open Source sponsorship program.