# Docker for Beginners: How to Containerize an App and Run It in the Cloud

> Markdown version of an Informer Tech article. Canonical HTML page: https://www.informertech.com/post/docker-tutorial-for-beginners
> Source: Informer Tech, https://www.informertech.com/

- **Canonical URL:** https://www.informertech.com/post/docker-tutorial-for-beginners
- **Publisher:** Informer Tech (https://www.informertech.com/)
- **Category:** DevOps, Beginner Guides
- **Author:** Tomáš Král
- **Published:** 2026-12-02
- **Description:** Follow this Docker tutorial for beginners to containerize an app, test it locally, run it in the cloud, and fix the most common errors along the way.

---

You followed a Docker tutorial for beginners, the app ran on your laptop, and then the guide ended. Nothing told you how to get it in front of anyone else. Or the build failed with an error that read like a cat walking across the keyboard.

This guide covers both gaps. You'll write a Dockerfile that packages your app, run the container locally to confirm it works, and then start it on a cloud server where others can reach it. Along the way, you'll learn how images, containers, and registries differ, and you'll get a plain-English fix list for the errors beginners hit most: unreachable ports, containers that exit immediately, and permission denied messages.

If you're comfortable installing software and typing a few terminal commands, that's enough. By the end, you'll have a containerized app running live in the cloud.

## What Docker Does and What You Need Before You Start

You've built an app that works on your laptop, then watched it break on a server. Docker fixes that. It packages your app with its dependencies, so it runs the same everywhere. For a small team, that means fewer "works on my machine" arguments and no one hand-configuring servers.

### Images, containers and registries in plain terms

What is Docker, in practice? Think of it as a recipe system (an analogy). The image is the recipe card with every ingredient listed. The container is the meal you cook from it, and you can cook many. The registry is the shared cookbook shelf where you store cards so a server can fetch them. That's the whole Docker image vs container distinction.

### Prerequisites checklist

- A working app that runs locally
- Docker installed (Docker Desktop on Windows or Mac, Docker Engine on Linux)
- Basic terminal comfort
- A cloud account
- A registry account, such as Docker Hub

Confirm the install by running <code>docker --version</code>, then <code>docker run hello-world</code>. If it prints a welcome message, you're ready.

## How to Containerize an App With a Dockerfile

A Dockerfile is a plain-text recipe Docker follows to containerize an app. Here's how to write a Dockerfile for a small Node.js web app.

### Write the Dockerfile

<pre class="ql-syntax" spellcheck="false">FROM node:20-slim
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]
</pre>
<code>FROM</code> picks the base image. <code>WORKDIR</code> sets the folder inside the container. Copying <code>package*.json</code> first means Docker caches the install step, so rebuilds skip it unless dependencies change. <code>EXPOSE</code> documents the port, and <code>CMD</code> starts the app.

Never hardcode secrets with <code>ENV</code> or <code>COPY</code>. Anyone with the image can read them. Pass them at runtime as environment variables.

### Add a .dockerignore and build the image

Create a <code>.dockerignore</code> file listing <code>node_modules</code>, <code>.git</code>, and <code>.env</code>. This keeps junk and secrets out of the image.

Then build:

<pre class="ql-syntax" spellcheck="false">docker build -t my-app .
</pre>
Success ends with a line like <code>naming to docker.io/library/my-app</code>. Run <code>docker images</code> and <code>my-app</code> appears in the list.

## Run and Test the Container on Your Own Machine

Running the image locally is the quickest way to find out whether your build actually works. Start it with a port mapping:

<pre class="ql-syntax" spellcheck="false">docker run -d --name myapp -p 8080:3000 myapp:1.0
</pre>
The mapping reads host:container. The right side, 3000, is the port your app listens on inside the container. The left side, 8080, is the port on your computer. Open <code>http://localhost:8080</code> or run <code>curl http://localhost:8080</code>. If the page or response comes back, it works.

One catch: your app must listen on all network interfaces (<code>0.0.0.0</code>), not just <code>localhost</code>. Inside a container, localhost means the container itself, so a server bound there can't be reached from outside.

To check on things:

<pre class="ql-syntax" spellcheck="false">docker logs myapp
docker ps
docker stop myapp
docker rm myapp
</pre>
Those show output, list running containers, stop the container, and delete it. Run <code>docker ps -a</code> to see stopped ones, too.

## Run Your Docker Container in the Cloud

Getting your container online means moving the image somewhere your cloud host can reach it, then starting it there.

### Push the image to a registry

Tag the image with your registry username, log in, then push: <code>docker tag myapp youruser/myapp:1.0</code>, <code>docker login</code>, <code>docker push youruser/myapp:1.0</code>. If you build on an Apple silicon laptop for an x86 server, add <code>--platform linux/amd64</code> to the build, or the container will fail on the host.

![](https://studio.informertech.com/assets/90a5e4d7-c06a-4ab8-b124-1352134e41fb.webp?width=1360&height=768)

### Start it on a cloud VM or managed container service

You have two routes. A basic virtual machine with Docker installed gives you more control but more setup. A managed container service needs less setup but gives you less control. Check current pricing and free tiers with your provider.

On a VM, pull and run: <code>docker run -d -p 80:3000 youruser/myapp:1.0</code>.

### Open the port and confirm the public endpoint

Add a firewall or security group rule allowing inbound traffic on the port you published, here 80. Then visit the VM's public IP in a browser, or run <code>curl http://YOUR_IP</code>. A response means it's live.

When you finish testing, stop or delete the VM and any related resources to avoid surprise charges.

## Docker Troubleshooting: Common Errors and How to Fix Them

Most Docker troubleshooting common errors come down to a few causes. Start with three diagnostic commands: <code>docker logs </code>, <code>docker inspect </code>, and <code>docker ps -a</code>, which lists stopped containers too.

### Build errors

**Symptom:** <code>COPY failed: file not found</code> or a missing module. **Cause:** the file sits outside the build context, or a dependency isn't in your requirements file. **Fix:** run <code>docker build</code> from the project folder and list every dependency.

### Container exits or won't start

**Symptom:** <code>docker ps</code> shows nothing. **Cause:** the main process crashed or finished. Run <code>docker ps -a</code>, then read the logs. For "port is already allocated," map a different host port, such as <code>-p 8081:8080</code>. For "permission denied" on the daemon, add your user to the <code>docker</code> group or use <code>sudo</code>.

### Works locally but not in the cloud

Suppose your app answers on your laptop but times out on the server. Check these:

- The app binds to <code>0.0.0.0</code>, not <code>localhost</code>.
- Environment variables exist on the server.
- The firewall allows the port.
- The image matches the server's architecture (ARM versus x86).
- You've logged in to your registry.

**Debugging order:** logs, port, network rule, image platform.

## Get Your Docker App Running Locally and in the Cloud

Three things matter most. Write a small Dockerfile that copies dependency files first and keeps secrets out through environment variables. Make sure the app listens on all interfaces inside the container. Then push the image to a registry and run it on a cloud host with the right port open.

Start with your smallest working app. Build it, run it locally, and confirm it responds before you touch the cloud. The pitfall to avoid is skipping that check, because most cloud failures are local mistakes you haven't caught yet. Building on an Apple silicon laptop for an x86 server is the other common trap.

You'll know it worked when the public address returns the same response your laptop did. If it doesn't, read the container logs first. They usually name the problem.
