Deploy Docker To Digitalocean

Deploy Docker To Digitalocean

Reading time1 min
#Cloud#DevOps#Containers#Docker#DigitalOcean#Droplets

Streamlining Production: Deploying Docker Containers on DigitalOcean's Droplets for Scalable Apps

Forget overly complex Kubernetes setups—learn how leveraging DigitalOcean Droplets with Docker can give startups and solo devs powerful, scalable deployments without drowning in configuration overhead.


When building scalable cloud-native applications, many developers think they need to jump straight into Kubernetes or other heavy orchestration tools. But what if you want to keep things simple, predictable, and still maintain the ability to scale efficiently? That’s where DigitalOcean Droplets + Docker containers come into play.

In this post, I’ll walk you through a practical guide on how to deploy Docker containers on DigitalOcean Droplets. This approach lets you:

  • Spin up reliable infrastructure quickly
  • Avoid the complexity of full-scale container orchestration
  • Maintain easy control over your deployment configuration
  • Scale apps smoothly while keeping cost predictable

Why Use Docker on DigitalOcean Droplets?

DigitalOcean Droplets are simple virtual private servers (VPS) that you can provision on-demand. They come with predictable pricing and are beginner-friendly. Docker containers package your app and its dependencies into lightweight, portable units that run consistently anywhere.

By combining the two:

  • You get a clean environment where you control resources.
  • You avoid vendor lock-in by deploying portable containers.
  • You optimize costs compared to over-provisioned cluster setups.
  • And for solo developers or small teams, management overhead stays minimal.

Step 1: Setting Up Your DigitalOcean Droplet

  1. Create a DigitalOcean account if you haven’t already.
  2. From the DigitalOcean dashboard, click "Create" > "Droplet".
  3. Choose an image:
    • Select Ubuntu 22.04 LTS (or any recent stable Linux).
  4. Pick a plan that fits your app’s needs (e.g., $5/mo Basic Droplet for small apps).
  5. Choose a data center region close to your users.
  6. Add SSH keys for secure access (recommended).
  7. Give the droplet a hostname, e.g., my-app-droplet.
  8. Click "Create Droplet".

After creation, you’ll get an IPv4 address — save it; you’ll use it to access the droplet.


Step 2: Access Your Droplet and Install Docker

Open your terminal (macOS/Linux) or use an SSH client like PuTTY (Windows). Connect to your Droplet using SSH:

ssh root@your_droplet_ip

Once logged in, update packages:

apt update && apt upgrade -y

Install Docker:

apt install -y docker.io

Enable and start Docker service:

systemctl enable docker
systemctl start docker

Verify installation:

docker --version

You should see something like Docker version 20.xx.x.

For convenience, add your user (or root) to the docker group:

usermod -aG docker $USER
newgrp docker

This allows running docker commands without sudo.


Step 3: Containerize Your App Locally

Assuming you’re working with a simple Node.js app as an example.

Here’s a sample Dockerfile:

FROM node:18-alpine

WORKDIR /app

COPY package*.json ./
RUN npm install --production

COPY . .

EXPOSE 3000

CMD ["node", "index.js"]

Build your image on your development machine:

docker build -t my-node-app .

Test it locally with:

docker run -p 3000:3000 my-node-app

Step 4: Push Your Image to Docker Hub (or Other Registry)

To deploy easily, push your image to a container registry accessible from the Droplet.

  1. Tag your image for Docker Hub:
docker tag my-node-app YOUR_DOCKERHUB_USERNAME/my-node-app:latest
  1. Log in to Docker Hub:
docker login
  1. Push the image:
docker push YOUR_DOCKERHUB_USERNAME/my-node-app:latest

Step 5: Pull and Run Your Container on the DigitalOcean Droplet

SSH back into your droplet if you aren’t already connected.

Pull the image from Docker Hub:

docker pull YOUR_DOCKERHUB_USERNAME/my-node-app:latest

Run the container detached at port 80 (you can pick any open port):

docker run -d -p 80:3000 --restart unless-stopped --name my-running-app YOUR_DOCKERHUB_USERNAME/my-node-app:latest
  • -d runs container in background.
  • --restart unless-stopped keeps it running through restarts/crashes.
  • -p 80:3000 maps droplet port 80 to container port 3000.

Now navigating to http://your_droplet_ip will show your app!


Step 6 (Optional): Set Up Firewall Rules via UFW

To secure your server:

Enable UFW firewall and allow SSH & HTTP traffic only:

ufw allow OpenSSH    # Allows SSH connections on port 22 by default.
ufw allow 80/tcp     # HTTP traffic.
ufw enable           # Turn firewall on.

Check status with ufw status.


Scaling Your Setup

If traffic grows beyond what a single Droplet can handle, you can horizontally scale by creating multiple droplets running identical containers behind a load balancer — DigitalOcean provides load balancers as managed add-ons that integrate seamlessly.

Alternatively, for simple scale-up, start with bigger droplets or add swap space if needed.


Summary & Benefits Recap

By deploying directly on DigitalOcean droplets with Docker containers you get:

BenefitExplanation
Fast provisioningSpin up VPS & deploy containers quickly
Low complexityAvoid hefty Kubernetes learning curve
Cost predictabilityControl plan size & number of droplets
Full controlCustomize configs & networking easily
PortabilityRun same images locally or elsewhere

This is often ideal for startups or solo developers aiming for simplicity without sacrificing scalability potential.


If you want even more automation down the road, tools like Ansible or Terraform can help automate provisioning/Docker deployment—but starting with this approach means you’re shipping cloud-native apps faster today.

Happy deploying! 🚀


Additional resources:


Have questions about deploying containers? Drop a comment below!