🚀 Getting Started with Docker: From Installation to Pushing Images to Docker Hub Part 1
BAKRE JAMIU

BAKRE JAMIU @jamiu_cloud

About: I am a enthusiastic Cloud Engineer.

Joined:
Sep 5, 2024

🚀 Getting Started with Docker: From Installation to Pushing Images to Docker Hub Part 1

Publish Date: Apr 29
0 0

If you're new to Docker or looking for a simple guide to go from setup to publishing your containerized app, this post is for you. In this tutorial, you'll learn how to:

  • Install Docker on Ubuntu
  • Build your first Docker image
  • Create and run a container
  • Tag and push your image to Docker Hub

Let’s get started.


🐳 Step 1: Install Docker on Ubuntu

Open your terminal and run the following commands:

sudo apt update
sudo apt install -y docker.io
Enter fullscreen mode Exit fullscreen mode

🔗 Alternative method:

For the latest version and installation options, check the official Docker install script:

To verify Docker is installed correctly:

docker --version
Enter fullscreen mode Exit fullscreen mode

or

docker -v
Enter fullscreen mode Exit fullscreen mode

📂 Useful Docker Commands

  • List Docker images:
docker image ls
Enter fullscreen mode Exit fullscreen mode
  • List Docker containers:
docker container ls
Enter fullscreen mode Exit fullscreen mode

🛠 Step 2: Build Your Docker Image

Let’s use a static website as an example, such as one downloaded from startbootstrap.com.

  1. Create a Dockerfile in your project directory:
nano Dockerfile
Enter fullscreen mode Exit fullscreen mode
  1. Add the following content:
FROM nginx:alpine
COPY . /usr/share/nginx/html
Enter fullscreen mode Exit fullscreen mode
  1. Build the Docker image:
docker build -t webapp:v1 .
Enter fullscreen mode Exit fullscreen mode

To confirm the image was created:

docker image ls
Enter fullscreen mode Exit fullscreen mode

Image description


🚀 Step 3: Run the Container

Now let’s run your image in a Docker container:

docker run -d -p 80:80 --name websiteapp webapp:v1
Enter fullscreen mode Exit fullscreen mode

Visit http://localhost:80 (or your server’s public IP) to see your site live.

To list running containers:

docker container ps
Enter fullscreen mode Exit fullscreen mode

Image description


🔐 Step 4: Log in to Docker Hub

If you don’t have a Docker Hub account, sign up here.

Then log in from your terminal:

docker login -u your_dockerhub_username
Enter fullscreen mode Exit fullscreen mode

Image description

You’ll be asked to enter your password or a Personal Access Token (PAT).


📦 Step 5: Tag & Push Your Image to Docker Hub

  1. Tag the image:
docker tag webapp:v1 your_dockerhub_username/webapp:v1
Enter fullscreen mode Exit fullscreen mode
  1. Push the image:
docker push your_dockerhub_username/webapp:v1
Enter fullscreen mode Exit fullscreen mode

Image description

You can now visit your Docker Hub profile and view your pushed image:

👉 https://hub.docker.com/repositories

Image description


After Successful Push

Image description


✅ Summary

In this guide, you learned how to:

  • Install Docker on Ubuntu
  • Build and run a Docker image
  • Host a simple static site using NGINX
  • Push your Docker image to Docker Hub

This workflow forms the backbone of containerized development. You can now use these skills to automate deployments, integrate with CI/CD pipelines, or scale with orchestration tools like Kubernetes.


💬 Have questions or want to learn how to automate deployment using GitHub Actions or AWS ECS? Leave a comment or reach out — I’d love to help!

Comments 0 total

    Add comment