Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres needs POSTGRES_PASSWORD at startup #1

Open
alfredo-f opened this issue Jan 12, 2021 · 0 comments
Open

Postgres needs POSTGRES_PASSWORD at startup #1

alfredo-f opened this issue Jan 12, 2021 · 0 comments

Comments

@alfredo-f
Copy link

Expected Behavior

In the network section, container for Postgres should start up without any environment variables.

$ docker run --rm -d --name widgetdb --network skynet -p 5432 postgres
7f0248e3c0f4f03159ef966fd9767a4c7e3412801f8b0445cebb933d1e84e020
$ docker run --rm -d --name gadgetdb --network skynet -p 5432 postgres
8dc66701837c695728abb9046db71924112a9b8f2f1e096094ab5b5d631e2f73
$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                     NAMES
8dc66701837c        postgres            "docker-entrypoint..."   11 seconds ago      Up 10 seconds       0.0.0.0:32769->5432/tcp   gadgetdb
7f0248e3c0f4        postgres            "docker-entrypoint..."   40 seconds ago      Up 39 seconds       0.0.0.0:32768->5432/tcp   widgetdb
$

Current Behavior

The environment variable POSTGRES_PASSWORD must be specified at startup.

$ docker run --rm -d --name widgetdb --network skynet -p 5432 postgres
4f20eef0f61b876170ad92a1234370e251b8c3e508fc63eca6058240555e5930
$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                    PORTS               NAMES
4f20eef0f61b        postgres            "docker-entrypoint.s…"   3 seconds ago       Exited (1) 1 second ago                       gadgetdb
$ docker logs widgetdb 
Error: Database is uninitialized and superuser password is not specified.
       You must specify POSTGRES_PASSWORD to a non-empty value for the
       superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".

       You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
       connections without a password. This is *not* recommended.

       See PostgreSQL documentation about "trust":
       https://www.postgresql.org/docs/current/auth-trust.html
$

Possible Solution

$ docker run --rm -d -e POSTGRES_PASSWORD=strongpass --name widgetdb --network skynet -p 5432 postgres
f776a6e9c78d0103e7a0afd1ba16394b8b51a016fe7fd1a5b586de6304e383fa
$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                     NAMES
f776a6e9c78d        postgres            "docker-entrypoint.s…"   35 seconds ago      Up 33 seconds       0.0.0.0:32771->5432/tcp   widgetdb
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant