Jim
Jim

Reputation: 4425

Not possible to override command with CMD or Entrypoint

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?

Upvotes: 0

Views: 305

Answers (1)

Paolo
Paolo

Reputation: 26220

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

Upvotes: 2

Related Questions