Home > database >  docker don't create container psql in ubuntu
docker don't create container psql in ubuntu

Time:03-29

I'm type command

sudo docker run --name=todo-db -e POSTGRESS_PASSWORD='1234' -p 5436:5432 -d --rm postgres

After which I get "030cdf850...."

Input

sudo docker ps -a

and I get an empty table

CodePudding user response:

try this command to run your psql in ubuntu. Good luck...

docker run --rm -it -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_USER=postgres -e POSTGRES_DB=InitialDB postgres

CodePudding user response:

Not sure why you're trying to use --rm for database instance, but here is why you can't create:

-e POSTGRESS_PASSWORD='1234'

is not correct. You have two S in your environment variable while it should has only one S. If you remove --rm and run it again, then run docker logs todo-db, you'll see this:

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

. So, use this:

docker run --name=todo-db -e POSTGRES_PASSWORD='1234' -p 5436:5432 -d --rm postgres

Also keep in mind that to debug the reason why container is not created, do not use --rm to see the exited one in docker ps -a output to check the logs.

  • Related