Published on

How to Set Up Your First Docker Container in 10 Minutes

Docker containers allow you to package an application and all its requirements into a single unit that runs identically on any computer. You can set up your first container in under 10 minutes by installing Docker Desktop and running a simple command like docker run hello-world in your terminal. This process eliminates the "it works on my machine" problem by ensuring the software environment remains consistent across different operating systems.

Why should you use Docker containers?

Traditional software installation often fails because one computer has a different version of a library (a collection of pre-written code) than another.

Docker solves this by using containers.

A container is a lightweight, standalone package of software that includes everything needed to run an application, such as code, runtime, system tools, and settings.

Using containers means you don't have to worry about breaking your computer's main settings.

Each container is isolated, meaning it operates in its own little bubble without interfering with other programs.

We’ve found that this isolation is the best way for beginners to experiment with new tools like Python 3.12+ or Node.js 22 without cluttering their system.

How do you install and verify Docker?

Before you can run a container, you need the Docker engine installed on your machine.

For beginners, the easiest way to do this is by downloading Docker Desktop, which provides a visual interface to manage your containers.

As of October 2026, you should ensure your operating system is up to date.

Windows users should be on Windows 11 version 26H2 or newer.

Mac users should be running macOS 17 or later to ensure full compatibility with the latest Docker features.

  1. Step 1: Download the installer. Visit the official Docker website and select the version for your operating system.
  2. Step 2: Run the installation wizard. Follow the prompts, ensuring you grant the necessary permissions for system networking.
  3. Step 3: Launch Docker Desktop. Once installed, open the application and wait for the status icon in the corner to turn green, indicating the engine is running.
  4. Step 4: Verify the version. Open your terminal (Command Prompt on Windows or Terminal on Mac) and type docker --version.
  5. What you should see: The terminal should return a version number, likely Docker version 30.x.x or higher, confirming the installation worked.

What are the core concepts you need to know?

Before running commands, it helps to understand the difference between an Image and a Container.

Think of an Image as a blueprint or a recipe for a cake.

It is a read-only file that contains the instructions for creating a container.

A Container is the actual cake baked from that recipe.

It is a running instance of an image.

You can have one image (the blueprint) and use it to start ten different containers (the running programs) at the same time.

Another key term is a Registry.

A Registry is a digital storage locker where images are kept.

Docker Hub is the most popular public registry where developers share images for common software like databases or web servers.

How do you run your first container?

Now that the software is installed, you can pull an image from the registry and run it.

We will start with a tiny program designed specifically for testing.

  1. Step 1: Open your terminal. You can use the built-in terminal in VS Code or your system’s default command line.
  2. Step 2: Execute the run command. Type the following command and press Enter:
    docker run hello-world
    # 'docker run' tells Docker to find an image and start it
    # 'hello-world' is the name of the specific image we want
    
  3. Step 3: Observe the output. Docker will look for the image on your computer. When it doesn't find it, it will "pull" (download) it from Docker Hub automatically.
  4. What you should see: A message starting with "Hello from Docker!" will appear, explaining that your installation appears to be working correctly.

How do you run a web server in a container?

Running a "Hello World" script is a good start, but Docker is mostly used for running services like web servers.

In this example, you will run Nginx (a popular web server used to deliver content on the internet).

  1. Step 1: Run the Nginx container with a port mapping. Type this command:
    docker run --name my-web-server -d -p 8080:80 nginx
    # --name gives your container a friendly nickname
    # -d stands for 'detached' mode, which runs the container in the background
    # -p 8080:80 maps port 8080 on your computer to port 80 inside the container
    
  2. Step 2: Check if it is running. Type docker ps to see a list of all active containers.
  3. Step 3: View the result. Open your web browser and go to localhost:8080.
  4. What you should see: A page saying "Welcome to nginx!" which confirms your containerized web server is live.

How do you manage and stop your containers?

Containers don't disappear just because you close your terminal window.

If you leave them running, they will continue to use your computer's RAM (Random Access Memory - the short-term memory your computer uses to run apps).

To see all containers, including the ones that have stopped, use the command docker ps -a.

The -a flag stands for "all."

To stop the web server you just created, use the stop command followed by the name you gave it:

docker stop my-web-server
# This gracefully shuts down the running application

If you want to delete the container entirely to save space, use the rm (remove) command:

docker rm my-web-server
# This deletes the container instance, but keeps the image on your disk

To remove the image itself, you would use docker rmi nginx.

Don't worry if you delete an image by mistake; you can always download it again from the registry.

What are common mistakes beginners make?

One frequent issue is forgetting that containers are ephemeral (temporary).

If you save a file inside a container and then delete the container, that file is gone forever.

To save data permanently, you must use Volumes (a way to link a folder on your physical hard drive to a folder inside the container).

Another common "gotcha" is port conflicts.

If you try to run two containers on port 8080 at the same time, the second one will fail.

Always ensure the first number in your -p 8080:80 command is unique for every container you run.

Lastly, ensure Docker Desktop is actually running.

It is normal to see an error saying "Cannot connect to the Docker daemon" if you forget to open the Docker application before using the terminal.

Simply launch the app and wait 30 seconds for the engine to start.

Next Steps

Now that you have successfully run a web server, you are ready to explore more complex setups.

You might try creating a Dockerfile (a text file that contains instructions to build your own custom image) or using Docker Compose to run multiple containers at once, such as a website and its database.

We recommend trying to containerize a simple Python script or a React 19 application next.

This will help you understand how to move your own code into the Docker ecosystem.

For more detailed guides, visit the official Docker documentation.


Read the Your Documentation