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 docker --version, then docker run hello-world. 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
FROM node:20-slim WORKDIR /app COPY package*.json ./ RUN npm install COPY . . EXPOSE 3000 CMD ["node", "server.js"]
FROM picks the base image. WORKDIR sets the folder inside the container. Copying package*.json first means Docker caches the install step, so rebuilds skip it unless dependencies change. EXPOSE documents the port, and CMD starts the app.
Never hardcode secrets with ENV or COPY. Anyone with the image can read them. Pass them at runtime as environment variables.
Add a .dockerignore and build the image
Create a .dockerignore file listing node_modules, .git, and .env. This keeps junk and secrets out of the image.
Then build:
docker build -t my-app .
Success ends with a line like naming to docker.io/library/my-app. Run docker images and my-app 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:
docker run -d --name myapp -p 8080:3000 myapp:1.0
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 http://localhost:8080 or run curl http://localhost:8080. If the page or response comes back, it works.
One catch: your app must listen on all network interfaces (0.0.0.0), not just localhost. Inside a container, localhost means the container itself, so a server bound there can't be reached from outside.
To check on things:
docker logs myapp docker ps docker stop myapp docker rm myapp
Those show output, list running containers, stop the container, and delete it. Run docker ps -a 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: docker tag myapp youruser/myapp:1.0, docker login, docker push youruser/myapp:1.0. If you build on an Apple silicon laptop for an x86 server, add --platform linux/amd64 to the build, or the container will fail on the host.

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: docker run -d -p 80:3000 youruser/myapp:1.0.
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 curl http://YOUR_IP. 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: docker logs , docker inspect , and docker ps -a, which lists stopped containers too.
Build errors
Symptom: COPY failed: file not found or a missing module. Cause: the file sits outside the build context, or a dependency isn't in your requirements file. Fix: run docker build from the project folder and list every dependency.
Container exits or won't start
Symptom: docker ps shows nothing. Cause: the main process crashed or finished. Run docker ps -a, then read the logs. For "port is already allocated," map a different host port, such as -p 8081:8080. For "permission denied" on the daemon, add your user to the docker group or use sudo.
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
0.0.0.0, notlocalhost. - 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.

