AWS Lambda function returns "errorMessage": "[Errno 30] Read-only file system: '/home/sbx_user1051'"

Question:

I get the following error

{
  "errorMessage": "[Errno 30] Read-only file system: '/home/sbx_user1051'",
  "errorType": "OSError",
  "stackTrace": [
    "  File "/var/lang/lib/python3.8/imp.py", line 234, in load_modulen    return load_source(name, filename, file)n",
    "  File "/var/lang/lib/python3.8/imp.py", line 171, in load_sourcen    module = _load(spec)n",
    "  File "<frozen importlib._bootstrap>", line 702, in _loadn",
    "  File "<frozen importlib._bootstrap>", line 671, in _load_unlockedn",
    "  File "<frozen importlib._bootstrap_external>", line 843, in exec_modulen",
    "  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removedn",
    "  File "/var/task/app.py", line 3, in <module>n    nltk.download('stopwords')n",
    "  File "/var/task/nltk/downloader.py", line 777, in downloadn    for msg in self.incr_download(info_or_id, download_dir, force):n",
    "  File "/var/task/nltk/downloader.py", line 642, in incr_downloadn    yield from self._download_package(info, download_dir, force)n",
    "  File "/var/task/nltk/downloader.py", line 699, in _download_packagen    os.makedirs(download_dir)n",
    "  File "/var/lang/lib/python3.8/os.py", line 213, in makedirsn    makedirs(head, exist_ok=exist_ok)n",
    "  File "/var/lang/lib/python3.8/os.py", line 223, in makedirsn    mkdir(name, mode)n"
  ]
}

when testing my lambda function. I don’t understand what this error is telling me to do about the docker image I am using, if that even is the correct route to explore. What should I do

Asked By: vecohah

||

Answers:

AWS Lambda is not a generic docker runner. The docker containers you deploy to Lambda have to comply with the AWS Lambda runtime environment.

The docker image you are using is trying to write to the path /home/sbx_user1051 apparently. On AWS Lambda the file system is always read-only except for the /tmp path. You will have to modify the code running in the docker image to prevent it from writing anywhere else but /tmp/.

Answered By: Mark B