'Getting error "The container name is already in use by container "93b7..." (docker ps gives nothing) [duplicate]

I'm trying to run postgres docker:

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

I'm getting error message:

docker: Error response from daemon: Conflict. The container name "/some-postgres" is already in use by container "93b72872c89cf7497872b0bc0e98d5a91078666945e3ca39ce5cbb36c436b5af". You have to remove (or rename) that container to be able to reuse that name.

I checked with:

sudo docker ps

And there is nothing:

CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

(Empty)

  1. so, why I'm getting this error message ?
  2. If the container name already exsits, How can I run it ?


Solution 1:[1]

Try running

docker ps -a you will see existing container name and remove that using docker rm some-postgres. and run the docker run command again.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dashrath Mundkar