---
title: How to Encrypt your Data at Rest using Docker and AWS Elastic Beanstalk
description: Learn how to encrypt the data at rest when running an application on an AWS Elastic Beanstalk environment using Docker and meet HIPAA requirements.
---

[Welcome to the Nexton Blog | Nexton](https://blog.nexton.dev)

# [How to Encrypt your Data at Rest using Docker and AWS Elastic Beanstalk](https://blog.nexton.dev/how-to-encrypt-your-data-at-rest-using-docker-and-aws-elastic-beanstalk)

 Written by [Fabricio Pautasso](https://blog.nexton.dev/author/fabricio-pautasso) | Oct 6, 2020, 7:00:00 AM

When developing a healthcare application, one of the regulations that will come into play will be HIPAA. One of the requirements of this regulation related to data at rest is that it needs to be encrypted.

In this post, we will go through how to encrypt our data at rest when running an application on an AWS Elastic Beanstalk environment using Docker.

<https://images.ctfassets.net/k4d8pgyc7rbq/31lEKZjBXcXh5JteAaqO09/2dc44a4b88b0f79b6854aa7d18d743c1/ebs-docker.jpeg>

## Problem

> Our dockerized application is being deployed to an Elastic Beasntalk environment where the EBS volumes attached to the EC2 machines, where the containers are running, are not being encrypted

## Solution

There are a couple of tutorials out there on how to enable encryption on a new **EBS** volume attached to an **EC2** like:

[https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html)

[https://cloudacademy.com/blog/how-to-encrypt-an-ebs-volume-the-new-amazon-ebs-encryption/](https://cloudacademy.com/blog/how-to-encrypt-an-ebs-volume-the-new-amazon-ebs-encryption/)

The issue we faced while trying these approaches is that as we were using **Docker**, when you encrypt the **EBS** attached to the **EC2** machine, just the root volume is being encrypted (**/dev/xvda**), while the new volume being generated by **Docker** when the container is deployed (**/dev/xvdcz**) was left unencrypted.

To fix the problem, we need to follow the next steps:

1. Login to AWS Management console and go to EC2 section
2. EC2 Dashboard → Settings
3. Select Always encrypt new EBS volumes and save changes

<https://images.ctfassets.net/k4d8pgyc7rbq/5bkJD4SbhBlAF3BVAxYQcn/8000a50e65a259af9347ec1378271aa2/ebs-volume.png>

1. Go to Elastic Beanstalk section and choose the application/environment you want to encrypt
2. Click on Actions → Rebuild Environment

<https://images.ctfassets.net/k4d8pgyc7rbq/4FNx0EwKOXM0jWDJJgozj7/f7ca5a9d0ef8cd2bce3bbbfbb4d3db18/rebuild.png>

This will terminate the current EC2 machine that is running your dockerized application and its related volumes. It will create a new EC2 machine where all the volumes created/attached to it are encrypted.

1. Go back to EC2 → EC2 dashboard → Settings
2. Disable the encryption enabled on step 3

 

 

 

[View full post](https://blog.nexton.dev/how-to-encrypt-your-data-at-rest-using-docker-and-aws-elastic-beanstalk)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Fabricio Pautasso"
  },
  "dateModified" : "2023-07-05T18:32:00.920Z",
  "datePublished" : "2020-10-06T07:00:00Z",
  "headline" : "How to Encrypt your Data at Rest using Docker and AWS Elastic Beanstalk",
  "image" : {
    "@type" : "ImageObject",
    "height" : 1013,
    "url" : "https://f.hubspotusercontent20.net/hubfs/14573977/Nxt%20Blog%20Aws%20EBS.png",
    "width" : 2160
  },
  "mainEntityOfPage" : "https://blog.nexton.dev/how-to-encrypt-your-data-at-rest-using-docker-and-aws-elastic-beanstalk",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "Nexton's blog"
  }
}
```