Docker Error: No such container: friendlyhello

There is no container available with the name friendlyhello as you are simply running the container using docker run -p 4000:80 friendlyhello, here friendlyhello is the name of the image, and not the container's name.

Either run that container by giving it a name like below:-

docker run -p 4000:80 --name SOMENAME friendlyhello

In this case you will be able to stop and remove that container using the below command

# container stop
docker container stop SOMENAME

# container removal
docker rm -f SOMENAME

Or if not running without giving a name to the container, you will have to use the ID of the container in the commands to stop and remove, even in various other commands you will be using the ID to refer that con


The tutorial shows:

$ docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED
1fa4ab2cf395        friendlyhello       "python app.py"     28 seconds ago

You haven't added a name (tag) to your container, so you must use its ID to stop it:

docker container stop 1fa4ab2cf395

friendlyhello is the name of the image, not the container.

See docker run --name to give it a name.

If you don't have a name, you will the ID with docker ps -a

The OP adds:

using docker stop 8e008ebf3ad7 its out of list using: docker container ls buts stays in list using: docker ps -a

docker stop 8e008ebf3ad7
8e008ebf3ad7
docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS
               NAMES
5227976cb9bb        friendlyhello       "python app.py"     About an hour ago   Up About an hour    0.0.0.0:4001->80/tcp   SOMENAME

docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS
     PORTS                  NAMES
5227976cb9bb        friendlyhello       "python app.py"     About an hour ago   Up About an hour
     0.0.0.0:4001->80/tcp   SOMENAME
8e008ebf3ad7 friendlyhello "python app.py" 6 hours ago Exited (137) About an hour ago 

That is expected: a stop will put a container in an "Exited" state, which is handy when you want to debug a container which stopped without your consent!

You can then do a docker container rm <ID> in order to reomve it from the docker ps -a list.

Note that if you had launch your container with docker run --rm ..., a stop would have stopped and removed (deleted) the container directly.