DevOps

    Installing and Running Your First Docker Container


    Introduction

    Today, we’re getting hands-on with Docker, the most popular containerization tool. We’ll install Docker on your local machine and run your first container. By the end, you’ll see how easy it is to spin up isolated environments. Let’s get started!

    Why Docker?

    Docker makes containers accessible. It allows you to build, share, and run apps in containers effortlessly. Key benefits:

    • Isolation: Apps run in their environment without interfering with your system.

    • Portability: "Build once, run anywhere."

    • Efficiency: Faster than VMs.

    As of 2025, Docker remains the standard, with the latest versions available via official docs.

    Step 1: Installing Docker

    Docker installation varies by OS. Follow the official guides for the latest steps (from docs.docker.com).

    For Windows:

    1. Download Docker Desktop from docker.com.

    2. Run the installer and follow prompts. Enable WSL 2 if prompted.

    3. Open Docker Desktop to verify it's running.

    For macOS:

    1. Download Docker Desktop for Mac.

    2. Open the DMG file, drag to Applications, and launch.

    3. Grant permissions if needed.

    For Linux (Ubuntu example):

    1. Update packages: sudo apt-get update

    2. Install prerequisites: sudo apt-get install ca-certificates curl

    3. Add Docker's GPG key: sudo install -m 0755 -d /etc/apt/keyrings followed by curl command from docs.

    4. Add repo: sudo apt-get update

    5. Install: sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

    6. Verify: sudo docker run hello-world

    Tip: Use the official install script for simplicity on Linux: 

    curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh

    Step 2: Running Your First Container

    Once installed, open a terminal and run:

    docker run hello-world

    This pulls the hello-world image from Docker Hub and runs it. Output should confirm Docker is working.

    Troubleshooting:

    • If "permission denied," add your user to the docker group: sudo usermod -aG docker $USER and log out/in.
    • Network issues? Check firewall or proxy settings.
    Hello world Docker

     

    Step 3: Basic Docker Commands

    Let’s explore essentials:

    • docker ps: List running containers.

    • docker images: List local images.

    • docker pull nginx: Download an image (e.g., NGINX web server).

    • docker run -d -p 8080:80 nginx: Run NGINX in detached mode, mapping port 8080 to 80. Visit http://localhost:8080.

    Experiment: Run docker run -it ubuntu bash for an interactive Ubuntu shell.

    Today’s Takeaway

    You’ve installed Docker and run your first container-congrats! This sets the foundation for building custom images in the next COE.

    Ready to transform your business with our technology solutions? Contact Us today to Leverage Our DevOps Expertise. 

    Contact Us

    Comment

    Share

    facebook
    LinkedIn
    Twitter
    Mail
    Devops

    Related Center Of Excellence