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


๐Ÿš€ 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


๐Ÿ” 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

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

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

๐Ÿ‘‰ https://hub.docker.com/repositories


After Successful Push


โœ… 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!

Top comments (0)