Getting Started with Docker: A Beginner’s Guide to Containerization

Docker Basics | ARKSD Consultancy Private LimitedIn the ever-evolving realm of software development, speed and efficiency are essential. Imagine having the power to package an application and all its dependencies into a single, standardized unit that can run consistently across different environments. This is where Docker, a revolutionary containerization platform, comes into play. In this beginner’s guide, we’ll embark on a journey to demystify Docker, exploring its installation and basic usage.

What is Docker?

Docker is an open-source platform designed to make it easier to create, deploy, and run applications by using containers. Containers are lightweight and standalone executable packages that contain everything needed to run a piece of software, including the code, runtime, libraries, and system tools. They provide consistency, portability, and isolation, making it easier to manage applications across different environments.

Step 1: Installation

The first step on your Docker journey is installing the Docker Desktop application. Docker is available for various operating systems, including Windows, macOS, and Linux.

  • For Windows:
    • Ensure that you have a Windows version that supports Hyper-V(Windows Server 2008 and later versions).
    • Go to the Docker Desktop website and click on the Get Docker button. This will download the Docker Desktop Installer.exe file to your computer.
    • Run the installer and grant administrator privileges if required. You will see a Configuration page where you can choose to use WSL 2 or Hyper-V as the backend for Docker Desktop. WSL 2 is recommended for Windows 10 and 11, while Hyper-V is required for Windows containers.
    • Follow the instructions on the installation wizard to complete the installation process. You may need to restart your computer for the changes to take effect.
    • After the installation is done, you can launch Docker Desktop from the Start menu or the system tray. You will see a Docker icon in the taskbar indicating that Docker Desktop is running.

  • You should always opt for signing up with Docker Desktop because it will offer you several benefits . Like :-
    •  Unlimited public repositories so you can share your custom container images with your team, customers, or the Docker community at large.
    • It will provide you up to 200 image pulls per day from Docker Hub including access to Docker Official images and Docker Verified Publisher images so you can build securely from the start

You have successfully signed up for Docker Desktop and reached the Docker Hub website. Docker Hub is the world’s largest library and community for container images. You can use it to:

  • Explore over 100,000 container images from software vendors, open-source projects, and the community
  • Create your own repositories and share your container images with your team or the Docker community

To get started with Docker Hub, you can follow our blog on Docker Hub Quickstart tutorial guide.

Step 2: Verification

Once installed, it’s time to verify that Docker is up and running. Open a terminal or command prompt and run the following command:

docker –version

This command should display the Docker version you installed, confirming that Docker is installed correctly.

Step 3: Running Your First Container

With Docker installed, let’s dive into running your first container. To run a simple container, open your command prompt and type the following:

docker run hello-world

**Make sure to open command prompt in administrative mode to follow this tutorial .

Docker will fetch the “hello-world” image from Docker Hub if it’s not already available locally. It will then run the container, which prints a friendly message and exits. Docker Hub is a repository of container images that you can use as a starting point for your applications.

Step 4: Exploring Docker Images

Docker images serve as the blueprint for containers. You can think of them as pre-packaged applications. To list the Docker images available on your system, use the following command:

docker images

This command displays a list of images, including their names, tags, sizes, and when they were created.

Step 5: Running a Container from an Image

Now, let’s run a container from an image. Choose an image from Docker Hub that interests you, and replace "your-image-name" with the image name. For example, to run a basic web server:

docker run -d -p 80:80 --name my-web-server nginx

  • -d runs the container in detached mode.
  • -p 80:80 maps port 80 from the container to port 80 on your host machine.
  • --name my-web-server assigns a name to the container.
  • nginx is the name of the Docker image.

You now have a running web server accessible at http://localhost in your web browser.

Step 6: Managing Containers

Docker provides numerous commands to manage containers. Here are a few essential ones:

  • docker ps: Lists running containers.

Docker ps is a command that lists the containers on your system. The -a option (or –all) shows all containers, including the ones that are not running. For example,  we have a container named hello-world that is stopped, you can see it with docker ps -a, but not with docker ps.

  • docker stop <container-name>: Stops a running container.

We have a Docker container named “my-web-server” which was created from the official Nginx image . To halt the execution of this container,we will issue the command “docker stop my-web-server” . Following this, we will verify the list of active containers by executing the command “docker ps”.

  • docker start <container-name>: Starts a stopped container.

  • docker rm <container-name>: Removes a container.

What’s Next?

This beginner’s guide has introduced you to the world of Docker containerization. You’ve learned how to install Docker, run containers, manage images, and even deploy a simple web server. But this is just the tip of the iceberg. Docker offers an entire ecosystem of tools and features to explore, making it a powerful ally in modern software development.

Next, you can delve into creating your Docker images, setting up multi-container applications using Docker Compose, and exploring orchestration with tools like Docker Swarm or Kubernetes. The possibilities are endless, and Docker’s vast community and resources are there to guide you on your containerization journey. So, go ahead, experiment, and embrace the efficiency and consistency that Docker brings to your development workflow. Happy containerizing! 🐳

You may consider advancing your skills with our DevOps Architect Training. This comprehensive course covers advanced Docker topics like Docker Swarm, Kubernetes, Docker Compose, and much more. Gain the expertise you need to excel in modern software development and take your career to new heights.

Leave a Comment

Your email address will not be published. Required fields are marked *

CAPTCHA ImageChange Image


This will close in 20 seconds

    Your Cart
    Your cart is emptyReturn to Shop
    Scroll to Top