Sponsored

Thursday, November 5, 2026

Docker for Beginners: Run Your First Container and Understand the Commands


DevOps
· By Kashmitha Madushan · 4 November 2026

Docker is easier to learn when you stop treating it as a collection of mysterious commands. Start with one image, run a container, inspect it, and delete it. Those four actions explain much of the workflow you will use later with ASP.NET Core or other applications.

What is an image, and what is a container?

An image is a packaged template containing the software and instructions needed to run an application. A container is a running or stopped instance of an image. You can create multiple containers from the same image without copying your entire project by hand.

1. Install Docker Desktop or Docker Engine

Follow Docker's official installation guide for your operating system. On Windows, verify the WSL 2 requirements and ensure virtualization is enabled. After installation, open a terminal and run:

docker --version
docker info

The first command displays client information. The second checks whether Docker can communicate with its engine.

2. Run a container

docker run --name demo-nginx -d -p 8080:80 nginx:stable

This starts an Nginx web server in the background. The mapping 8080:80 forwards port 8080 on your machine to port 80 in the container. Visit http://localhost:8080 in your browser.

3. Inspect and stop it

docker ps
docker logs demo-nginx
docker stop demo-nginx
docker ps -a
docker rm demo-nginx

docker ps lists running containers. docker logs helps when startup fails. Stopping a container does not remove it; that is why the cleanup command is separate.

4. Where does a Dockerfile fit?

A Dockerfile tells Docker how to build an image from your own application. When you reach that stage, learn FROM, WORKDIR, COPY, RUN and CMD. Don't confuse building an image with starting a container.

Common problems

If the command says it cannot connect to the Docker daemon, check that Docker Desktop or the engine is running. If port 8080 is already in use, pick a different available host port. If image downloads fail, verify network access and any corporate proxy settings.

Practice idea: run two Nginx containers on different host ports, then stop and remove both. That one exercise builds confidence quickly.

Further reading: Official reference documentation.

Kashmitha Madushan writes about development, DevOps, Unity and practical software workflows. Examples are educational drafts; check the steps in your own environment before relying on them.

No comments:

Post a Comment

Practical developer tutorials, AI tool comparisons, troubleshooting guides and free software resources.

Search This Blog

Powered by Blogger.

Blog Archive

Git troubleshooting: choose the right fix without losing work

Choose a Git command from the change you want to inspect, not from a list of commands to try. Staged edits, unstaged edits, untracked files ...