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:
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
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.
Open a terminal or command prompt.
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.
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!
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!
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!
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:
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:
Start the Docker daemon.
Pull an image (the "hello-world" image).
Run a new container from the pulled image.
Verify that your container is running.
Inspect your container's details.
Stop your container.
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
My interests
As a techie + proud Hindhu i love to know/write about technology, spiritual knowledge.
Hey!, I am not living library. But if there is topic if you want me to cover, I will do my research and write about it, if it is unfamiliar to me. Its fun to learn and grow together.
Contact ID
Contact
author@luminari.info
© 2024. All rights reserved.
Well usually everyone goes with explaining containers and pod, like workloads but we feel it's better to know architectures first with those questions in the head. we will explain about work loads but now lets jump in with architecture and components.
Well usually everyone goes with explaining containers and pod, like workloads but we feel it's better to know architectures first with those questions in the head. we will explain about work loads but now lets jump in with architecture and components.