<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: FlashRDP</title>
    <description>The latest articles on DEV Community by FlashRDP (@flashrdp).</description>
    <link>https://dev.to/flashrdp</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4271434%2F0babe96d-8d24-4e8b-96c6-4fa7820fd32b.jpg</url>
      <title>DEV Community: FlashRDP</title>
      <link>https://dev.to/flashrdp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/flashrdp"/>
    <language>en</language>
    <item>
      <title>Persistent Docker Deployments on an Ubuntu VPS (Volumes, Traefik, Backups)</title>
      <dc:creator>FlashRDP</dc:creator>
      <pubDate>Sat, 28 Nov 2026 22:11:10 +0000</pubDate>
      <link>https://dev.to/flashrdp/persistent-docker-deployments-on-an-ubuntu-vps-volumes-traefik-backups-hmj</link>
      <guid>https://dev.to/flashrdp/persistent-docker-deployments-on-an-ubuntu-vps-volumes-traefik-backups-hmj</guid>
      <description>&lt;p&gt;&lt;strong&gt;To keep Docker data across restarts and rebuilds, store it in named volumes or bind mounts, never only inside the container; then back those volumes up off the server.&lt;/strong&gt; This guide sets that up on an Ubuntu VPS with Docker Compose and a Traefik reverse proxy.&lt;/p&gt;

&lt;p&gt;A container's own filesystem is thrown away when the container is removed or recreated. Anything you need to keep, such as database files or uploads, must live in a volume.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bind mounts vs. volumes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bind mounts&lt;/strong&gt; map a host folder (for example &lt;code&gt;/opt/app/data&lt;/code&gt;) into the container. Handy for config files you edit by hand.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Named volumes&lt;/strong&gt; are managed by Docker under &lt;code&gt;/var/lib/docker/volumes&lt;/code&gt;. They're the usual choice for database data such as PostgreSQL or MySQL.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Install Docker
&lt;/h2&gt;

&lt;p&gt;Install Docker Engine and the Compose plugin with Docker's official convenience script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can read &lt;code&gt;get-docker.sh&lt;/code&gt; before running it. Docker also documents a manual &lt;code&gt;apt&lt;/code&gt; repository install, which gives you more control on production servers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Write a Compose file with persistent storage
&lt;/h2&gt;

&lt;p&gt;This &lt;code&gt;compose.yml&lt;/code&gt; runs Traefik as a reverse proxy in front of a web app whose data lives in a named volume:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;traefik&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;traefik:v3&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"--providers.docker=true"&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"--providers.docker.exposedbydefault=false"&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"--entrypoints.web.address=:80"&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"80:80"&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/var/run/docker.sock:/var/run/docker.sock:ro&lt;/span&gt; &lt;span class="c1"&gt;# Lets Traefik discover containers
&lt;/span&gt;    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;

  &lt;span class="na"&gt;webapp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-web-app:latest&lt;/span&gt;
    &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"traefik.enable=true"&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"traefik.http.routers.webapp.rule=Host(`example.com`)"&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"traefik.http.routers.webapp.entrypoints=web"&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;webapp_data:/app/persistent_data&lt;/span&gt; &lt;span class="c1"&gt;# Named volume: survives container rebuilds
&lt;/span&gt;    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;webapp_data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start it with &lt;code&gt;sudo docker compose up -d&lt;/code&gt;. Add HTTPS with Traefik's Let's Encrypt support before going live; see the &lt;a href="https://doc.traefik.io/traefik/https/acme/" rel="noopener noreferrer"&gt;Traefik documentation&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Don't publish Traefik's dashboard (&lt;code&gt;--api.insecure=true&lt;/code&gt; on port &lt;code&gt;8080&lt;/code&gt;) on a public server: it has no login. Also note that ports published by Docker bypass &lt;code&gt;ufw&lt;/code&gt; rules, so only publish ports you mean to expose, or bind them to &lt;code&gt;127.0.0.1&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Step 3: Back up your volumes
&lt;/h2&gt;

&lt;p&gt;Volumes survive container restarts, not disk failures or an accidental &lt;code&gt;docker volume rm&lt;/code&gt;. On an unmanaged VPS the provider runs the hardware, network and power, and you own the OS, containers and application data, so backups are your job.&lt;/p&gt;

&lt;p&gt;Back up a volume to a compressed archive in the current folder with a temporary container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo docker run --rm -v webapp_data:/volume:ro -v &lt;span class="s2"&gt;"$(pwd)"&lt;/span&gt;:/backup ubuntu \
  tar czf /backup/webapp_data-&lt;span class="nv"&gt;$(&lt;/span&gt;date +%F&lt;span class="o"&gt;)&lt;/span&gt;.tar.gz -C /volume .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Schedule it nightly with &lt;code&gt;cron&lt;/code&gt; and copy the archives off the server, for example to S3-compatible storage.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; For databases, back up with the database's own tool (&lt;code&gt;pg_dump&lt;/code&gt;, &lt;code&gt;mysqldump&lt;/code&gt;) or stop the container first. Copying a live database's files can produce a backup that won't restore.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Many VPS providers also offer server-level snapshots or backups. Use them as a second layer, not a replacement for volume backups you can restore on any host.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I work on &lt;a href="https://flashrdp.com" rel="noopener noreferrer"&gt;FlashRDP&lt;/a&gt;, a Windows RDP and Linux VPS host. This guide was first published in our docs: &lt;a href="https://flashrdp.com/docs/guides/docker-compose-deployment-recovery" rel="noopener noreferrer"&gt;Persistent Docker Deployments on Ubuntu VPS&lt;/a&gt;. Everything above works on any Ubuntu server.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>ubuntu</category>
      <category>devops</category>
      <category>selfhosted</category>
    </item>
  </channel>
</rss>
