DEV Community

Cover image for Master Docker in Minutes: Your Ultimate Hands-On Guide to Containerization
Oluwatobiloba Akinbobola
Oluwatobiloba Akinbobola

Posted on

Master Docker in Minutes: Your Ultimate Hands-On Guide to Containerization

INTRODUCTION

Containerization has transformed software development, deployment, and management. Docker, a leading containerization platform, stands out for its simplicity and efficiency. This hands-on lab will guide you through the basics of Docker, empowering you to leverage containerized applications with confidence.

Lab 1: Installing Docker

  1. Install Docker:
    • Download Docker Desktop from the official website.
    • Follow the installation instructions for your operating system.
  2. Verify Installation:
    • Open a terminal or command prompt and run:
docker --version
docker-compose --version
Enter fullscreen mode Exit fullscreen mode

This confirms Docker is installed and ready to use.

Lab 2: Running Your First Container

Step 1: Get the Sample Application

  • Clone the sample application repository:
git clone https://github.com/docker/welcome-to-docker
Enter fullscreen mode Exit fullscreen mode

Image description
Alternatively, download the repository manually.

Step 2: Explore the Dockerfile
A Dockerfile defines the contents of a container. Open the Dockerfile in your project folder to understand its structure.

Step 3: Build Your First Image

  • Build the Docker image:
docker build -t welcome-to-docker .
Enter fullscreen mode Exit fullscreen mode

welcome-to-docker
The -t flag tags the image with a name (welcome-to-docker).
The . specifies the location of the Dockerfile.

Step 4: Run Your Container
1.Use Docker Desktop to run the container:
Docker Desktop

  • Go to the Images tab, select your image, and click Run. Host Port-8080 2.Set the Host Port to 8080. Host Port 8080

Step 5: View the Frontend

Access the running container via Docker Desktop or navigate to https://docs.docker.com/get-started/introduction/ in your browser.
Log
Image Containers

Step 6: Stop Your Container
Stop the container in Docker Desktop by selecting the Stop icon in the Containers tab.
Stop

Summary
This article walked you through building and running your first Docker container. You also learned how to use Docker Desktop to manage containers and images.

Reference
For more advanced use cases, explore images on Docker Hub and refer to the official Docker documentation.

Top comments (0)