Home > Mobile >  Not possible to override command with CMD or Entrypoint
Not possible to override command with CMD or Entrypoint

Time:10-30

I am executing the following command from the postgres doc

docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres

Now out of curiosity I run the following:

docker run -it --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres bash

and I don't end up with an interactive bash shell.
Also trying:

docker run -it --name some-postgres --entrypoint bash -e POSTGRES_PASSWORD=mysecretpassword -d postgres

does not work either.

How come I am not able to override the default command?

CodePudding user response:

The command is working properly, but since you are using the -d flag the container is being started in the background. Remove that flag and you'll be in an interactive bash session:

docker run -it --name some-postgres --entrypoint bash -e POSTGRES_PASSWORD=mysecretpassword postgres
  • Related