Unlock Full Control: Deploying with Dokploy, Docker, and MySQL


Unlock Full Control: Deploying with Dokploy, Docker, and MySQL

Dokploy/dokploy

2025-07-27

Let's break down how Dokploy can be incredibly useful from a software engineer's perspective, along with implementation details and sample code.

Imagine having the power to deploy your web applications, APIs, and microservices with the simplicity of a platform-as-a-service (PaaS) like Heroku, but with the full control of your own infrastructure. That's essentially what Dokploy brings to the table.

It's a self-hosted solution that leverages Docker under the hood, allowing you to deploy and manage your applications, databases (like MySQL, as highlighted), and even handle backups, all from a user-friendly interface.

Key Benefits for Software Engineers

Cost Efficiency
Say goodbye to escalating bills from third-party PaaS providers as your applications scale. With Dokploy, you pay for your own server, and that's it. This can lead to significant savings, especially for growing projects or multiple applications.

Full Control & Customization
Unlike managed services that often abstract away the underlying infrastructure, Dokploy gives you direct control. You can configure your servers, networking, and even tweak Docker settings to perfectly match your application's needs. This is invaluable for performance optimization, security hardening, and integrating with specific tools.

Data Sovereignty & Security
For sensitive applications, keeping your data on your own servers is often a critical requirement. Dokploy ensures your data stays within your controlled environment, enhancing security and compliance.

Local Development Parity
Since Dokploy uses Docker, your local development environment (running Docker Compose, for example) can closely mirror your production environment. This reduces "it works on my machine" issues and streamlines the development-to-deployment pipeline.

Seamless MySQL & Docker Integration
The mention of "MySQL" and "Docker" highlights Dokploy's strength in handling common web application stacks. It simplifies the deployment of Dockerized applications that rely on MySQL databases, including automated backups.

Open Source Community
Being open source means you can inspect the code, contribute to its development, and benefit from a community of users and developers. This fosters transparency and innovation.

Alternative to Vendor Lock-in
By self-hosting, you avoid being locked into a specific provider's ecosystem. If your needs change, you have the flexibility to migrate more easily.

Let's dive into some practical scenarios where Dokploy truly shines for a software engineer

Deploying Microservices
If you're building a microservices architecture, Dokploy provides an excellent platform to deploy and manage each service independently. You can easily scale individual services based on demand.

Hosting Internal Tools & Dashboards
For internal applications that don't need the public exposure of a commercial PaaS, Dokploy offers a secure and cost-effective hosting solution. Think about internal CRMs, analytics dashboards, or team collaboration tools.

Rapid Prototyping & MVPs
Need to get an idea off the ground quickly without worrying about complex server setup? Dokploy's streamlined deployment process makes it ideal for rapidly deploying prototypes and Minimum Viable Products (MVPs).

E-commerce Platforms
Applications relying heavily on databases like MySQL, such as e-commerce stores, can benefit from Dokploy's robust database management and backup features.

Personal Projects & Portfolio Sites
For personal projects, a blog, or a portfolio website, Dokploy provides a professional and scalable hosting solution without breaking the bank.

Dev/Staging Environments
You can easily spin up multiple instances of Dokploy to create dedicated development, staging, and production environments, ensuring a smooth deployment pipeline.

The beauty of Dokploy lies in its relatively straightforward setup. Here's a general outline of the steps involved

Prerequisites

A Virtual Private Server (VPS)
You'll need a Linux-based VPS (e.g., Ubuntu, Debian, CentOS) from providers like DigitalOcean, Vultr, Linode, AWS EC2, or Google Cloud Compute Engine. The server should have at least 2GB RAM for basic usage, but more is recommended for production applications.

Domain Name (Optional but Recommended)
For accessible applications, a domain name pointing to your VPS's IP address is essential.

SSH Access
You'll need SSH access to your VPS to perform the installation.

Installation (General Steps)

Dokploy typically offers a simple installation script. The process usually involves

Connecting to your VPS via SSH

ssh your_user@your_server_ip

Updating your server's packages

sudo apt update && sudo apt upgrade -y # For Ubuntu/Debian

Running the Dokploy installation script
(Please refer to the official Dokploy documentation for the most up-to-date installation instructions, as they might evolve.) It's often a one-liner like

curl -sSL https://dokploy.com/install.sh | sudo bash

This script will usually install Docker, Docker Compose, and all necessary Dokploy components.

Following the on-screen prompts
The installer might ask you for some initial configurations, such as your domain name, admin email, and a password for the Dokploy dashboard.

Initial Setup & Configuration

Once installed, you'll typically access the Dokploy dashboard via your web browser at the domain name you configured (or your server's IP address if you didn't set up a domain yet).

From the dashboard, you'll be able to

Add Projects
Organize your applications into logical projects.

Add Servers
If you want to expand Dokploy across multiple servers, you can add them here.

Configure Git Integrations
Connect your Git repositories (GitHub, GitLab, Bitbucket, or self-hosted Git).

Set up SSL/TLS
Dokploy usually integrates with Let's Encrypt for free SSL certificates, making it easy to secure your applications.

Let's imagine you have a simple Node.js application that connects to a MySQL database.

Project Structure (Example)

my-node-app/
├── src/
│   └── app.js
├── Dockerfile
├── package.json
└── .env.example

Dockerfile (Example - Node.js)

# Use an official Node.js runtime as a parent image
FROM node:18-alpine

# Set the working directory in the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install any needed packages
RUN npm install

# Copy the rest of the application code
COPY . .

# Expose the port your app runs on
EXPOSE 3000

# Define the command to run your app
CMD ["npm", "start"]

app.js (Example - Node.js with MySQL)

const express = require('express');
const mysql = require('mysql');
require('dotenv').config(); // For local development

const app = express();
const port = process.env.PORT || 3000;

// Database connection
const connection = mysql.createConnection({
  host: process.env.DB_HOST || 'localhost',
  user: process.env.DB_USER || 'root',
  password: process.env.DB_PASSWORD || 'password',
  database: process.env.DB_NAME || 'mydatabase'
});

connection.connect((err) => {
  if (err) {
    console.error('Error connecting to MySQL:', err.stack);
    return;
  }
  console.log('Connected to MySQL as id ' + connection.threadId);
});

app.get('/', (req, res) => {
  res.send('Hello from Dokploy! Application is running.');
});

app.get('/users', (req, res) => {
  connection.query('SELECT * FROM users', (error, results) => {
    if (error) {
      console.error('Error fetching users:', error);
      res.status(500).send('Error fetching users');
      return;
    }
    res.json(results);
  });
});

app.listen(port, () => {
  console.log(`Application listening at http://localhost:${port}`);
});

Deployment Process with Dokploy

Create a New Application in Dokploy

Log in to your Dokploy dashboard.

Navigate to your chosen "Project" or create a new one.

Click "Add Application" (or similar).

Connect to Your Git Repository

Select your Git provider (GitHub, GitLab, etc.).

Authorize Dokploy to access your repositories.

Choose the repository containing your my-node-app.

Select the branch you want to deploy (e.g., main or master).

Configure Application Settings

Port
Specify the port your application listens on (e.g., 3000 from your Dockerfile).

Build Type
Dokploy will likely detect your Dockerfile. If not, select "Dockerfile" as the build type.

Domains
Add the domain name you want to use for your application (e.g., mynodeapp.yourdomain.com). Dokploy will typically handle SSL provisioning automatically.

Environment Variables
This is crucial for connecting to your MySQL database. You'll add variables like

DB_HOST
The internal hostname Dokploy provides for your MySQL service.

DB_USER
Your MySQL username.

DB_PASSWORD
Your MySQL password.

DB_NAME
Your MySQL database name.

PORT
3000 (matching your app.js).

Add a MySQL Database

Within the Dokploy dashboard, usually under "Databases" or "Services," you'll find an option to "Add MySQL Database."

Provide a name for your database, set a username and password.

Dokploy will provision a MySQL instance for you and provide the necessary connection details (host, port, username, password, database name).

Important
Use the internal host provided by Dokploy for DB_HOST in your application's environment variables. This ensures your application can communicate with the database securely within the Dokploy network.

Deploy!

Once all settings are configured, trigger the deployment from the Dokploy dashboard.

Dokploy will pull your Git repository, build the Docker image (based on your Dockerfile), and deploy your application. You'll see logs of the build and deployment process.

Behind the Scenes
Dokploy essentially creates a Docker container for your application and another for your MySQL database, setting up a secure internal network for them to communicate. It also handles routing external traffic to your application's container.

One of Dokploy's strengths is its integrated backup functionality, especially for databases like MySQL.

Automated Backups
You'll typically configure automated backup schedules directly within the Dokploy dashboard for your MySQL databases. You can set the frequency (daily, weekly), retention policy, and even the storage location (e.g., local server, S3-compatible storage).

Manual Backups
You should also have the option to trigger manual backups when needed, for example, before a major application update.

Restoration
Dokploy should provide a straightforward process to restore your database from a backup. This is crucial for disaster recovery.

From an engineering perspective, having these features built-in and manageable from a single dashboard is a huge time-saver and significantly reduces the operational overhead of maintaining your applications.


Dokploy/dokploy




Winapps: Seamlessly Integrate Windows Apps into Your Linux Workflow

Imagine you're a Linux user, maybe you're developing on a powerful Ubuntu machine because of its excellent command-line tools and development environment


Boosting Productivity: Why DBeaver Should Be Your Go-To Database Tool

Here is a friendly explanation of how DBeaver can help you, along with guidance on adoption and a simple usage example, all from a software engineer's perspective


Technical Breakdown: How TrendRadar's NLP Features Streamline Software Engineering Tasks

Here is a friendly, detailed breakdown, focusing on the technical value and implementation steps.The sansan0/TrendRadar project is essentially a sophisticated AI-driven news aggregation and monitoring system


Stirling-PDF: Your Privacy-First PDF Toolkit for Engineers

Stirling-PDF is a locally hosted web application that provides a full suite of PDF manipulation tools. Think of it as your personal


Scaling with Plane: Deploying an Open-Source Linear Alternative with Docker

You've pointed out a very exciting project. Plane is a powerful, open-source project management tool designed to be a streamlined alternative to Jira or Linear


Simplifying LLM Tooling with IBM's mcp-context-forge

Think of mcp-context-forge as a central hub for your Large Language Model (LLM) applications. In a typical setup, your LLM might need to access various tools


The Engineer's Blueprint: Deep Diving into Docker, Kafka, and the DataTalksClub Course

Think of Data Engineering as the "plumbing" of the tech world. Without it, even the most advanced AI models are just Ferraris with no fuel


Streamline Your Kitchen with Tandoor Recipes: A Software Engineer's Perspective

While Tandoor Recipes is a tool for food and meal management, its underlying structure and features can be a great asset for a software engineer


containerd: The Engine Driving Modern Container Runtimes

containerd is a core container runtime that manages the complete container lifecycle of its host system. It's an open-source project donated to the Cloud Native Computing Foundation (CNCF) and provides a robust


DIY Monitoring for Engineers: Deploying Uptime Kuma with Docker

Uptime Kuma is a versatile and user-friendly self-hosted monitoring tool that provides a slick, modern dashboard for keeping tabs on your applications and services