Reputation: 536
I have an efs drive, with shared files, that i want to mount inside docker containers to be run on ECS. AWS has a suggested way to do it using task definition. However, I want to do it using docker-compose and not change task definitions that we manage through console etc.
I am attaching snippet I am using below, but shared drive doesn't get mounted and gives following error per below. It comes as empty and doesnt show shared efs. Can someone suggests as to what am I doing incorrectly here and how can i change dockerfile or docker-compose yml to get desired results.
docker-compose.yml
version: "3.9"
services:
server:
build: .
image: xyz
command: "gunicorn -w 4 -k uvicorn.workers.UvicornWorker app.server:server -b 0.0.0.0:8000"
volumes:
- type: volume
source: efs_volume
target: /mnt/efs_xyz
volumes:
efs_volume:
driver: local
driver_opts:
type: "nfs4"
o: "addr=fs-xxxxxx.efs.useast1.amazonaws.com,rw,nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport"
device: ":/"
Below is my Dockerfile
FROM python:3.8-slim-buster
RUN apt-get update -y && apt-get install -y \
vim \
g++ \
unixodbc-dev \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt Docker* docker* .docker* ./app/
RUN python -m pip install --no-cache-dir -r requirements.txt
Error when running docker-compose up
Cannot start service server: error while mounting volume '/var/lib/docker/volumes/app_efs_volume/_data': failed to mount local volume: mount :/:/var/lib/docker/volumes/app_efs_volume/_data, data: addr=fs-0bb4dbbf.efs.us-east-1.amazonaws.com,nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport: invalid argument
Upvotes: 2
Views: 3023
Reputation: 21
As per this answer, only type: nfs
(not type: nfs4
) allows to use addr=<hostname>
.
Upvotes: 2