# Can I set up a container volume from the EBS volume on the host EC2 instance?

**URL:** <https://community.convox.com/t/can-i-set-up-a-container-volume-from-the-ebs-volume-on-the-host-ec2-instance/743>\
**Category:** Rack (Version 2)\
**Created:** [May 17, 2020, 7:12am UTC](https://community.convox.com/t/can-i-set-up-a-container-volume-from-the-ebs-volume-on-the-host-ec2-instance/743 "2020-05-17T07:12:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nathan.f77](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.convox.com/nathan.f77/32/256_2.png) [@nathan.f77](https://community.convox.com/u/nathan.f77)\
**Post date:** [May 17, 2020, 7:12am UTC](https://community.convox.com/t/can-i-set-up-a-container-volume-from-the-ebs-volume-on-the-host-ec2-instance/743/1 "2020-05-17T07:12:35Z")

</div>

Hello,

I’ve been profiling some of my background jobs, and I discovered that an S3 download step is taking up a large percentage of the time (between 20% and 50%.) The same files are being used repeatedly, so I would like to start caching these locally.

It would be easy to set up an ephemeral cache inside the Docker containers, but then this would be blown away every time a container restarts. Also each container would need to maintain their own cache, so this would not be an efficient use of disk space.

I’m reading the [EFS FAQ](https://aws.amazon.com/efs/faq/):

> Q: When should I use Amazon EFS vs. Amazon S3 vs. Amazon Elastic Block Store (EBS)?  
> …  
> Amazon EBS can deliver performance for workloads that require the lowest-latency access to data from a single EC2 instance.

As far as I understand, Convox uses EFS for any volumes defined in convox.yml. (At least, for version 2 racks.)

I think it might be better if I could mount a local volume from each EC2 instance (from the EBS volume), because the performance would be much better. Each set of containers on a single instance would share the same volume. For my case, it’s totally fine if a container on instance A doesn’t see the same files as a container on instance B.

One advantage of an EFS volume is that the file cache would be shared across all of my EC2 instances. I might need to be careful about lock contention, since every process would be accessing and updating the same cache. (But I probably won’t need to worry about that for a long time.)

Is there something I can modify in convox.yml, or maybe in a custom AMI?

---

<div class="post-metadata">

**Author:** ![nathan.f77](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.convox.com/nathan.f77/32/256_2.png) [@nathan.f77](https://community.convox.com/u/nathan.f77)\
**Post date:** [May 17, 2020, 7:33am UTC](https://community.convox.com/t/can-i-set-up-a-container-volume-from-the-ebs-volume-on-the-host-ec2-instance/743/2 "2020-05-17T07:33:47Z")

</div>

I just read through the [“AWS EFS — The Container Friendly File System” blog post](https://convox.com/blog/efs), and that explained a lot! I actually didn’t realize that Convox was already mounting an EFS volume at `/volumes`, so I already have a directory that is shared between all of the instances.

So if I use this format:

```auto
  volumes:
    - /var/lib/postgresql/data

```

Then Docker will create a new volume inside `/volumes` by default.

So if I specify an explicit path outside of the `/volumes` directory, then I guess this means I’m using EBS instead of EFS. E.g. something like:

```auto
  volumes:
    - /tmp/filecache:/tmp/filecache

```

UPDATE: Ahhhh, this doesn’t work. This creates a volume inside: `/volumes/<myapp>/tmp/filecache`

So it looks like I don’t have the option to mount a volume outside the `/volumes` directory.
