DEV Community

Abdullah Sheikh
Abdullah Sheikh

Posted on

How to Deploy a Docker App to Any VPS in Under 10 Minutes

Deploy your containerized app to a fresh VPS from zero to live in less than ten minutes

Before We Start: What You'll Walk Away With

By the end of this guide you’ll have a live Docker container humming on a brand‑new VPS, ready to serve traffic.

One command will spin up the whole stack, so you can treat deployment like ordering a pizza: you pick the toppings, hit “place order,” and the kitchen does the rest.

All the tools you’ll touch are free or have a generous freemium tier, meaning you can start without spending a dime.

  • Connect to a fresh VPS and install Docker in seconds.

  • Push your app’s image to a public registry.

  • Run a one‑line script that pulls the image, creates a container, and sets up a basic firewall.

  • Quick start: curl -sSL https://example.com/deploy.sh | bash

  • Rollback ready: The script saves the previous container ID, so you can revert with a single command.

  • Zero‑config networking: Uses the VPS’s default interface, no manual port forwarding needed.

This approach lets you skip the usual “install Docker, configure systemd, tweak iptables” maze and get straight to running code, just like using Google Maps to bypass traffic snarls.

When you finish, deploying a Docker app to VPS will feel as routine as packing a suitcase for a weekend trip—pick, zip, go.

What Deploying a Docker App Actually Is (No Jargon)

Deploying a Docker app means taking the container image you built on your laptop and copying it to a remote server so it runs there nonstop. The server pulls the image, starts a container, and keeps it alive until you decide to stop it.

Think of it like sending a pre‑packed lunch to a coworker’s desk. You’ve already prepared the sandwich, fruit, and napkin (the container). You drop the lunchbox at the office kitchen (the VPS), and a timer makes sure the food stays warm all day. No one has to re‑make the sandwich on site, and the lunch stays ready whenever it’s needed.

  • Copy the image with docker push or scp – like handing the lunchbox to the mailroom.

  • Start the container with docker run -d – like placing the lunch on a heated plate.

  • Monitor it with docker ps – like checking that the timer is still ticking.

When you deploy Docker app to VPS you’re basically automating that hand‑off so the app is up and running the moment the server boots, without manual re‑assembly.

The 3 Mistakes Everyone Makes With Docker VPS Deployments

Most of the time you spend fixing the same things over and over, and it slows you down.

  • Installing Docker manually on every new server – think of it like ordering a pizza for each friend individually instead of using the party‑size menu. You repeat the same steps, risk a typo, and waste precious minutes. Automate the install with a single script or a cloud‑init snippet, and you’ll get a clean, identical Docker engine on every VPS instantly.

  • Forgetting to open the right ports – it’s the digital equivalent of locking the front door while leaving the back window open. Your container runs, but the world can’t reach it. Make a habit of adding ufw allow 80/tcp or the specific port your app uses right after the Docker install, then verify with curl http://your‑vps-ip:PORT.

  • Running the container without a process manager – imagine packing a suitcase without tying the straps; the contents tumble out at the first bump. Without something like systemd or Docker’s built‑in restart policy, a reboot sends your app back to sleep. Use --restart unless-stopped in docker run or create a simple service file so the container boots up automatically.

Fix these three, and you’ll stop chasing ghosts when you deploy Docker app to VPS.

How to Deploy a Docker App: Step-by-Step

Grab a fresh Ubuntu 22.04 VPS and get it ready in five moves.

  • Pick a provider and launch the server. Think of it like ordering a pizza – you choose the crust (provider) and size (Ubuntu 22.04), then wait for delivery (instance).

  • SSH in and install Docker + firewall. Run a single command that does the heavy lifting.

ssh root@your-vps-ip
sudo apt-get update && sudo apt-get install -y ca-certificates curl gnupg
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
sudo ufw allow OpenSSH
sudo ufw allow 2375/tcp
sudo ufw --force enable
Enter fullscreen mode Exit fullscreen mode
  • Pull your image. This is like grabbing a ready‑made sandwich from the fridge.
docker pull yourusername/yourapp:latest
Enter fullscreen mode Exit fullscreen mode
  • Create a systemd service. The service is the “alarm clock” that wakes your container on boot.
sudo tee /etc/systemd/system/yourapp.service > /dev/null  /dev/null **UFW (Uncomplicated Firewall)** – Ubuntu’s built‑in guardrail works like a simple gate with three keys. One liner to open the necessary ports: 

Enter fullscreen mode Exit fullscreen mode


bash
ufw allow 22 && ufw allow 80 && ufw allow 443 && ufw enable


- **GitHub Actions** – Automate the build pipeline the way a coffee machine brews on schedule. A workflow file builds your Docker image on every push and pushes it to Docker Hub, so the VPS always pulls the latest tag.

With these tools in your toolbox, **deploy Docker app to VPS** becomes a repeatable, low‑effort routine.

## Quick Reference: Docker App Deployment Cheat Sheet

Grab a coffee and copy‑paste this list to get your Docker app running on any VPS in under ten minutes.

- **Prep** – Pick a VPS, write down its IP, and make sure your Docker image is pushed to a registry. Think of it like writing down an address before ordering a pizza.

**Install** – Run the one‑liner that drops Docker on the box and opens the needed ports:

Enter fullscreen mode Exit fullscreen mode


bash
curl -fsSL https://get.docker.com | sh && ufw allow 22 && ufw allow 80 && ufw enable


**Pull Image** – Grab the image you built earlier:

Enter fullscreen mode Exit fullscreen mode


bash
docker pull yourrepo/yourapp:tag


- **Service File** – Create `/etc/systemd/system/yourapp.service` with an `ExecStart` that runs the container. It’s the same as setting a “Start when I turn the key” rule for a car.

**Enable** – Start the service and let it survive reboots. For example, *Alex* a solo founder, runs:

Enter fullscreen mode Exit fullscreen mode


bash
systemctl enable --now yourapp


**Verify** – Confirm the container is alive and reachable:

Enter fullscreen mode Exit fullscreen mode


bash
docker ps
curl http://YOUR_IP:PORT


- **Tip** – Keep the service file minimal; only expose the ports you need.

- **Tip** – Use `--restart unless-stopped` in the `ExecStart` line to auto‑recover from crashes.

- **Tip** – If you change the image tag, just repeat steps 2–5; systemd will pick up the new container.

Copy, paste, and you’re live – that’s all it takes to *deploy Docker app to VPS*.

## What to Do Next

Kick the tires on your new setup by running a tiny “hello‑world” container and seeing it survive a reboot.

**Easy** – SSH into the VPS, pull `nginx:alpine`, and start it in detached mode:

Enter fullscreen mode Exit fullscreen mode


bash
docker run -d --name hello -p 80:80 nginx:alpine


Then reboot the server (`sudo reboot`) and check `docker ps`. If the container is still running, you’ve proven the deployment works—just like ordering a coffee, getting it, and watching it stay hot.
**Medium** – Wire a CI pipeline so every push builds a fresh image and pushes it to your registry. In GitHub Actions add a job that runs on `push` to `main`:

Enter fullscreen mode Exit fullscreen mode


yaml
name: Build & Deploy
on:
push:
branches: [main]
jobs:
docker:
runs-on: ubuntu-latest
steps:

  • uses: actions/checkout@v3
  • name: Log in to Docker Hub run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USER" --password-stdin
  • name: Build and push run: | docker build -t $DOCKER_USER/myapp:${{ github.sha }} . docker push $DOCKER_USER/myapp:${{ github.sha }}

Now each merge automatically refreshes the image—think of it as a kitchen that restocks ingredients every time a new order comes in.
**Hard** – Let infrastructure-as-code handle the whole stack. With Pulumi (TypeScript) you can spin up a VPS, open ports, install Docker, and deploy the container in one file:

Enter fullscreen mode Exit fullscreen mode


ts
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const droplet = new digitalocean.Droplet("app", {
region: "nyc3",
size: "s-1vcpu-1gb",
image: "ubuntu-22-04-x64",
userData: #!/bin/bash
apt-get update && apt-get install -y docker.io
docker run -d --restart unless-stopped -p 80:80 myrepo/myapp:latest
,
});

export const ip = droplet.ipv4Address;




Running `pulumi up` provisions everything, like using Google Maps to draw the entire road trip before you leave the house.

- **Cheat sheet**: keep `docker-compose.yml` ready for local testing; copy it to the VPS with `scp` when you need a quick redeploy.

- **Tip**: enable `--restart unless-stopped` on every container so reboots never drop your services.

Got a different stack or cloud provider? Drop a comment and let us know what tweaks you needed!

---

---

## About the Author

**[Abdullah Sheikh](https://abdullah-sheikh.com/)** is the Founder & CEO at [Exteed](https://exteed.com/), where he leads a team of skilled developers specializing in [Web2](https://abdullah-sheikh.com/) and [Web3 applications](https://abdullah-sheikh.com/), [Custom Smart Contracts](https://abdullah-sheikh.com/), and [Blockchain solutions](https://abdullah-sheikh.com/).

With 6+ years of experience, Abdullah has built [CRMs](https://abdullah-sheikh.com/), [Crypto Wallets](https://abdullah-sheikh.com/), [DeFi Exchanges](https://abdullah-sheikh.com/), [E-Commerce Stores](https://abdullah-sheikh.com/), [HIPAA Compliant EMR Systems](https://abdullah-sheikh.com/), and [AI-powered systems](https://abdullah-sheikh.com/) that drive business efficiency and innovation.

His expertise spans [Blockchain](https://abdullah-sheikh.com/), [Crypto & Tokenomics](https://abdullah-sheikh.com/), [Artificial Intelligence](https://abdullah-sheikh.com/), and [Web Applications](https://abdullah-sheikh.com/); building reliable and smooth web apps that fit the client’s goals and requirements.

📧 [info@abdullah-sheikh.com](mailto:info@abdullah-sheikh.com) · 🔗 [LinkedIn](https://www.linkedin.com/in/-abdullah-sheikh/) · 🌐 [abdullah-sheikh.com](https://abdullah-sheikh.com/)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)