Docker on Ubuntu 20.04.01 Tips

Don't install Docker from the Ubuntu software app, instead:

Follow this guide from Docker

$ sudo apt install docker.io

$ sudo apt-get install docker-compose

Verify install

$ docker–compose –version

Verify Docker

$ sudo docker run hello-world

To remove docker-compose

$ sudo apt-get remove docker-compose

$ sudo apt-get autoremove

Show all Docker container names and IP addresses

$ docker inspect -f '{{.Name}} - {{.NetworkSettings.IPAddress }}' $(docker ps -aq)

List Docker Images and Containers

To display a list of all Docker images stored locally:

$ sudo docker images ls –a

The –a option shows all docker images. You should see a listing with the hello-world image.

To see a list all containers use:

$ sudo docker ps -a

To view all currently running containers:

$ sudo docker ps

Note that this list is empty. This shows you that once the hello-world image completes, it closes out automatically.

Remove a Docker Image and Container

To remove a Docker image, you need to know its IMAGE ID. Use the command for listing images from the passage above to copy that information.

Once you have the ID, run the following syntax to erase that image:

$ docker image rm [IMAGE_ID]

You can also use this command to remove multiple Docker images:

$ docker image rm [IMAGE_ID1] [IMAGE_ID2] [IMAGE_ID3]

To remove a Docker container use:

$ docker rm [CONTAINER_ID]

Replace [CONTAINER_ID] with the actual container ID.

As you only used the one container, you should be able to remove the image:

$ docker rmi hello-world