Containers Have an Ephemeral Filesystem

During deployment, your application code is assembled as a static Docker image. This image is then used as the basis for running instances of your application. Therefore, if any files change inside the container during runtime, they are limited to that container only and will not be preserved across deployments. If you'd like to change this behavior, follow the procedures on this page.

Local File Storage

To use local file storage, you will need to configure Dokku so that your application stores dynamic content on the host system, instead of inside the container (which are ephemeral and are recreated each time you deploy).

  1. First, create a directory where your files will be stored on the server. We recommend using any path under the encrypted data volume (/data):
    mkdir -p /data/storage
    chown -R 32767:32767 /data/storage
  2. Next, configure your app to map the above path to a local path inside your application source tree. If your application is built using a buildpack, it will be rooted under a top directory named /app.
    dokku storage:mount my-app-name /data/storage:/app/some-path
  3. Finally, deploy your application and confirm that dynamic content is being saved to the proper location. Then run a restart command (dokku ps:restart my-app-name) to ensure everything is preserved. If everything is working correctly, you should see your files appear under /data/storage.

If you need to import files from another system, it's as easy as SCPing them to the /data/storage directory.

Note: if you need to share local storage between multiple Dokku-powered machines, we can provision shared network storage. Please create a help desk ticket if you need this option.

Amazon S3 Cloud Storage

We recommend using Amazon S3 for storing dynamically generated content such as images, videos, PDFs, etc. The cost of S3 is about six times less per 100GB vs. local storage. If your content contains any protected health information (PHI), you must use S3's server-side encryption option. Refer to the Amazon SDK documentation for your specific programming language, or contact us if you have problems finding what you need. Important note: only object data is encrypted; object names and metadata is not encrypted. Please contact us to provision an Amazon S3 bucket.