The underlying psql tool can be run with no arguments, in which case it will connect to the database defined by the PG* environment variables.
However, the same thing isn't possible with the alpine/psql image, because the Dockerfile contains CMD ["--help"], so running the image with no arguments just gives you the help output:
$ docker run -ti --rm alpine/psql
psql is the PostgreSQL interactive terminal.
Usage:
psql [OPTION]... [DBNAME [USERNAME]]
[...]
This means that you can't configure the Docker container with just environment variables - at least the database name has to be specified as a command-line argument.
It's not the end of the world, but I would still appreciate if you removed the default CMD. That way, the default behavior would match the underlying psql tool. One could still get the help message by passing --help explicitly.
The underlying
psqltool can be run with no arguments, in which case it will connect to the database defined by thePG*environment variables.However, the same thing isn't possible with the
alpine/psqlimage, because the Dockerfile containsCMD ["--help"], so running the image with no arguments just gives you the help output:This means that you can't configure the Docker container with just environment variables - at least the database name has to be specified as a command-line argument.
It's not the end of the world, but I would still appreciate if you removed the default
CMD. That way, the default behavior would match the underlyingpsqltool. One could still get the help message by passing--helpexplicitly.