1

I am using a multi-container Docker application in a EC2 linux instance. I have started it with: docker-compose -p myapplication up -d

I also have mounted my EFS under (in my EC2 host machine): /mnt/efs/fs1/

Everything is working fine at that point.

Now I need to access this EFS from one of my docker containers.

So I guess I have to add a volume to one of my containers linking /mnt/efs/fs1/ (in host) to /mydestinationpath (on container)

I can see my running containers IDs and images with: docker container ls

How can attach the volume to my container?

1 Answer 1

2

Edit the docker-compose.yml file to add the volumes: you need, and re-run the same docker-compose up -d command. Compose will notice that some specific services' configurations have changed, and delete and recreate those specific containers.

Most of the configuration for a Docker container (image name and tag, environment variables, published ports, volume mounts, ...) can only be specified when the container is first created. At the same time, the general expectation is that there's nothing important in a container filesystem. So it's extremely routine to delete and recreate a container to change options like this, and Compose can automate it for you.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.