DEV Community

Cover image for πŸš€ Getting Started with Docker: From Installation to Pushing Images to Docker Hub Part 1
BAKRE JAMIU
BAKRE JAMIU

Posted on

πŸš€ Getting Started with Docker: From Installation to Pushing Images to Docker Hub Part 1

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!

Tutorial image

Next.js Tutorial 2025 - Build a Full Stack Social App

In this 4-hour hands-on tutorial, Codesistency walks you through the process of building a social platform from scratch with Next.js (App Router), React, Prisma ORM, Clerk for authentication, Neon for PostgreSQL hosting, Tailwind CSS, Shadcn UI, and UploadThing for image uploads.

Watch the full video ➑

Top comments (0)

ITRS image

See What Users Experience in The Browser β€” Anywhere, Anytime

Simulate logins, checkouts, and payments on SaaS, APIs, and internal apps. Catch issues early, baseline web performance, and stay ahead of incidents. Easily record user journeys right from your browser.

Start Free Trial