Docker for Beginners Part 4 - Docker Images in More Details

Docker for Beginners Part 4 - Docker Images in More Details

Hello!

This is the Part 4 from the Docker series - Docker for Beginners in 8 Parts. In this post we're going to explore Docker Images in details!

  • Part 1 - Differences between Containers and Virtual Machines
  • Part 2 - Overview of Docker Installation for Mac and Ubuntu
  • Part 3 - Docker Images and Containers
  • Part 4 - Docker Images in Details
  • Part 5 - Docker Containers in Details
  • Part 6 - Building our own Docker Image with Dockerfile
  • Part 7 - Pushing our awesome Docker Image to Docker Hub
  • Part 8 - Keeping data with Docker Volume using MongoDB

Let's start the post by showing all Docker images that you already have locally

Showing all Docker Images in Your Machine

Do you remember that we pulled in the Docker Tomcat Image locally? Now let's go a little deep dive into it!

It's time to check another great docker command:

As you can see, this command will show you all images that you have locally.

My output shows me that I've pulled the following Docker Images:

Removing a Docker Image

If you don't like a specific Docker Image or maybe you dowloaded the wrong one, just remove it! For example, we can remove the Apache image:

This command will just remove the Docker Apache Image.

Just a warning: If you have a Docker Image being used by a Container, you should remove that container before remove the image.

In my case, a have a stopped Nginx container. If I try to remove the nginx image I got the following error:

Pulling different Docker Image Versions

Did you notice the message that has been printed on the console? That message started with the following:

Yes, makes sense! If you didn't choose a specific version of your desired Docker Image, then the latest should be downloaded for you.

Can I change for a desired version? Of course, you can!

As you can see, we choose the Tomcat version 7.

Pull Docker Images without Pulling it

Yes, we can pull an Image without use the docker pull command.

Let's try another Docker Image: the awesome Nginx image for example. We can just try to run the Nginx container and if its image does not exists locally, then Docker will try to download a new one.

The console would be the following

The first line indicates that we don't have the Nginx image locally and the next line is pulling the latest Nginx image.

Searching for Docker Images

We can search Docker Images from Docker Hub repository using the following command

The output would be the following

As you notice, Docker Hub repository hosts both official images as well as images that have been built by the great Docker community.

That's it!

Let's explore Docker images in more details in the next post of the Docker Series: Part 5 - Docker Containers in Details

Follow us to keep up to date!

Alexandre Gama

Alexandre Gama

Hacking Code Founder

Hacking Code Founder and Writer, Passionate Senior Software Engineer and Team Leader at @Elo7, Teacher of several courses at Caelum, Speaker at many conferences and terrible guitar player.
Docker for Beginners Tutorial - Containers vs Virtual Machines - Hacking Code

Part 1 - Containers vs Virtual Machines

This is the first Post of the Dockers series! We're going to explore differences between Containers and Virtual Machines!

Docker for Beginners Tutorial - Docker Installation - Hacking Code

Part 2 - Docker Installation on Mac and Ubuntu

Before hacking Docker commands we must install Docker!

Docker for Beginners Tutorial - Docker Images and Containers

Part 3 - Docker Images and Docker Containers

What's the differences between Docker Images and Docker Containers?

Docker for Beginners Tutorial - Docker Images

Part 4 - Docker Images in Details

It's time to explore more about Docker Images!

Docker for Beginners Tutorial - Containers in Details

Part 5 - Docker Containers in Details

It's time to explore more about Docker Containers!

Docker for Beginners Tutorial - Dockerfile - Hacking Code

Part 6 - Custom Docker Images with Dockerfile

Let's build your own custom Docker Image with Dockerfiles

Docker for Beginners Tutorial - Docker Hub

Part 7 - Pushing Docker Images to Docker Hub

Pushing your own great Docker Images to Docker Hub to exposes it to the World!

Docker for Beginners Tutorial - Docker Volumes - Hacking Code

Part 8 - Docker Volumes with MongoDB

Stop losing your data in the Docker Container by using Docker Volumes

0 Comments

Leave a Reply

Share This
Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

%d bloggers like this: