Learn Docker for free : Running first container

Learn Docker for free: Running first container, This a series/course for techies, who wish to learn docker. this page is focused on beginning of a new practical journey

DOCKER

- Luminari

7/3/20242 min read

Docker is a powerful tool for deploying and managing applications in containers. Containers are lightweight and portable, making them an ideal choice for developing, testing, and deploying applications. In this blog post, we'll walk you through the process of running your first Docker container.

Prerequisites

Before we begin, make sure you have:

  1. Docker installed: You can download and install Docker from the official website: https://www.docker.com/get-started/ ,and also checkout our blog Installing docker

  2. A basic understanding of Linux: Although not necessary, having a basic understanding of Linux commands will help you navigate the process. also checkout our blog for commonly used Linux commands

Step 1: Start the Docker Daemon

To start using Docker, you need to launch the Docker daemon (dockerd). The daemon is responsible for creating and managing containers on your machine.

  1. Open a terminal or command prompt.

  2. Run the following command to start the Docker daemon:

"sudo systemctl start docker"

Replace systemctl with service if you're using an older Linux distribution.

Step 2: Pull the "Hello World" Image

The "hello-world" image is a simple container that prints "Hello, World!" when run. This image is a great starting point for your first Docker container.

  1. Run the following command to pull the "hello-world" image:

"docker pull hello-world"

This command will download the "hello-world" image from Docker Hub (the official repository of Docker images).

Step 3: Run Your First Container

Now that you have the "hello-world" image, it's time to run your first container!

  1. Run the following command to start a new container:

"docker run hello-world"

This command will create a new container from the "hello-world" image and run it.

Step 4: Verify Your Container is Running

To verify that your container is running, you can use the docker ps command:

"docker ps"

This command will list all containers currently running on your machine. You should see the "hello-world" container listed in the output.

Step 5: Inspect Your Container

Now that your container is running, let's inspect it!

  1. Run the following command to get information about your container:

docker inspect hello-world

This command will provide details about your container, such as its IP address, port mappings, and environment variables.

Step 6: Stop Your Container

When you're finished exploring your container, let's stop it!

  1. Run the following command to stop your container:

docker stop hello-world

This command will send a signal to your container to shut down.

Step 7: Remove Your Container

Finally, let's remove your container:

  1. Run the following command to delete your container:

docker rm hello-world

This command will remove your "hello-world" container from your machine.

That's it! You've successfully run your first Docker container. In this guide, you learned how to:

  1. Start the Docker daemon.

  2. Pull an image (the "hello-world" image).

  3. Run a new container from the pulled image.

  4. Verify that your container is running.

  5. Inspect your container's details.

  6. Stop your container.

  7. Remove your container.

I know its a very simple, standard example. But KISS(Keep it simple stupid). You made a progress in next blog i will explain about docker commands