← Back to Articles         
Create and Run Your First Docker Container

Create and Run Your First Docker Container

Published on 04 Nov 2026 3 min read Docker
Docker Fundamentals

Understand Docker Images and Containers

Before creating our own application, let's understand two important Docker concepts.

1. What is a Docker Image?

A Docker Image is a read-only template containing everything required to run an application.

For example:

  • Application code

  • Runtime (such as .NET)

  • Dependencies

  • Configuration

Think of an image as a blueprint.

2. What is a Docker Container?

A Docker Container is a running instance of a Docker Image.

Think of it this way:

  • Image = Blueprint

  • Container = Running application created from that blueprint.

 

3. Practical Exercise

Open Command Prompt and execute the following commands one by one.

Command 1: List Docker Images

docker images

This displays downloaded images.

Command 2: List Running Containers

docker ps

This displays currently running containers.

Command 3: List All Containers

docker ps -a

This displays running and stopped containers.

Command 4: Download an Nginx Image

docker pull nginx

Nginx is a web server. Docker downloads its image from Docker Hub.

Command 5: Verify the Image

docker images

You should now see nginx in the image list.

Expected learning outcome

You should now understand:

Command

Purpose

docker images

List images

docker ps

List running containers

docker ps -a

List all containers

docker pull nginx

Download an image

 

Create and Run Your First Docker Container

Objective: Run an Nginx web server inside a Docker container and access it through your Windows browser.

1. Create an Nginx Container

Open Command Prompt and execute:

docker run -d -p 8080:80 --name my-nginx nginx

Explanation:

Parameter

Description

docker run

Creates and starts a container

-d

Runs in background (detached mode)

-p 8080:80

Maps Windows port 8080 to container port 80

--name my-nginx

Assigns a container name

nginx

Docker image name

2. Verify the Container

Execute:

docker ps

You should see something similar to:

CONTAINER ID   IMAGE   COMMAND   STATUS
xxxxxxxx       nginx   ...       Up ...

3. Access Nginx from Browser

Open Google Chrome or Edge.

Navigate to:

http://localhost:8080

You should see:

Welcome to nginx!

Congratulations! You have successfully deployed a web server inside a Docker container.

4. Stop the Container

Execute:

docker stop my-nginx

Refresh your browser. The website should no longer be accessible.

5. Start the Container Again

docker start my-nginx

Refresh the browser. Nginx should work again.

 

Commands learned

Command

Purpose

docker run

Create and run container

docker ps

Check running containers

docker stop

Stop container

docker start

Start stopped container

 
 
← Back to Articles