#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Docker Hub, Commands, and Security Guide for Beginners

Docker Hub is the public registry where most people first download container images and publish their own. This guide explains how it is organised, walks through the commands you will use every day, and lists the security habits worth building from the start.

Docker Hub, Commands, and Security Guide for Beginners

Docker Hub, Commands, and Security Guide for Beginners

Docker Hub basics

  • Image: a read-only template with an application and everything it needs to run.
  • Repository: a named collection of related images, such as nginx or yourname/myapp.
  • Tag: a label for one version in a repository, such as nginx:1.27-alpine. If you leave it out, Docker uses latest.
  • Digest: an exact content hash (sha256:…) that always refers to the same image bytes, unlike a tag, which can be moved.

Docker Hub marks trusted sources with badges: Docker Official Image (curated base images such as python, nginx, postgres), Verified Publisher (images from vendors whose identity Docker has checked) and Sponsored OSS (open-source projects in Docker's programme). Prefer these over random uploads.

Docker Hub also applies pull rate limits, which are lower for anonymous users than for signed-in accounts. If your CI pipeline pulls often, log in or use a mirror. The current limits are on Docker's "Usage and limits" documentation page.

New to containers in general? Start with Docker basics for beginners and what containers are in DevOps.

Everyday commands

Check the install

docker version
docker run hello-world

If everything works, the second command prints a message starting with Hello from Docker!.

Find, pull and run an image

docker search nginx                     # search Docker Hub from the terminal
docker pull nginx:1.27-alpine           # download a specific version
docker images                           # list local images
docker run -d --name web -p 8080:80 nginx:1.27-alpine
docker ps                               # running containers
docker logs web                         # container output
docker stop web && docker rm web        # stop and remove

-d runs the container in the background, and -p 8080:80 maps port 8080 on your machine to port 80 inside the container, so the page opens at http://localhost:8080.

Build, tag and push your own image

docker login -u yourname                # paste an access token, not your password
docker build -t myapp:1.0 .
docker tag myapp:1.0 yourname/myapp:1.0
docker push yourname/myapp:1.0
docker logout

The image name on Docker Hub must start with your username or organisation. Create the repository as private on Docker Hub first if the code is not meant to be public.

Clean up

docker image prune        # remove dangling images
docker system df          # see disk space used by Docker
docker system prune       # remove stopped containers, unused networks and dangling images

docker system prune asks for confirmation. Add -a only if you also want to delete all unused images.

Security habits

Your Docker Hub account

  • Turn on two-factor authentication.
  • Use personal access tokens for docker login and CI, with the narrowest permission (read-only for pulling), and revoke tokens you no longer use.
  • Keep anything containing internal code or configuration in private repositories.

Choosing images

  • Start from Official or Verified Publisher images, and check when the image was last updated.
  • Pin versions. Use python:3.12-slim rather than python:latest; for strict reproducibility pin the digest: python:3.12-slim@sha256:<digest>.
  • Prefer small bases (-slim, -alpine or distroless images). Fewer packages means fewer vulnerabilities to patch.
  • Scan images. Docker Scout is built into recent Docker versions: docker scout quickview myapp:1.0 gives a summary and docker scout cves myapp:1.0 lists known vulnerabilities. Open-source scanners such as Trivy do the same job.

Writing a safer Dockerfile

FROM python:3.12-slim
WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
RUN useradd --create-home appuser
USER appuser

CMD ["python", "app.py"]
  • USER appuser means the process does not run as root inside the container.
  • Add a .dockerignore file listing .git, .env, local data and build output so they never enter the image.
  • Never put passwords or API keys in a Dockerfile, ENV line or copied file. Every layer can be read by anyone who pulls the image. Use BuildKit secrets (RUN --mount=type=secret,...) at build time and environment variables or a secrets manager at run time.
  • Multi-stage builds let you compile in one stage and copy only the result into a small final image.

Running containers safely

docker run -d --name api \
  --read-only --tmpfs /tmp \
  --cap-drop ALL \
  --security-opt no-new-privileges \
  --memory 512m --pids-limit 200 \
  -p 8000:8000 yourname/myapp:1.0
  • Avoid --privileged, and do not mount /var/run/docker.sock into a container unless you understand that it gives control of the host's Docker.
  • Publish only the ports you need, and bind to 127.0.0.1 for services that should not be reachable from the network.
  • Keep the Docker Engine and host OS updated.

To take an image from Docker Hub to a cloud server, see deploying container apps with Docker and AWS. For the wider toolchain around containers, DevOps for beginners is a good next read.

FAQs

Is Docker Hub free?

Docker Hub has a free personal plan with public repositories and limited private use, plus paid plans with higher pull limits and more features. Check Docker's pricing page for current limits.

What is the difference between docker pull and docker run?

docker pull only downloads an image. docker run creates and starts a container from an image, and pulls the image first if it is not already on your machine.

Should I use the latest tag?

Not in production. latest simply means whatever was pushed last, so it can change under you. Use a specific version tag, or a digest for exact pinning.

Placed Students

Our Clients

Partners

...