You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows 7环境下用Docker创建AWS Lambda Layer遇文件找不到错误求助

Hey there, sorry you've been stuck on this all day—let's break this down step by step to get it working.

First, Fix the Command Syntax Issue

You combined the cd and docker run commands in one line without a proper separator, which means the cd command never actually runs. Docker tries to look for requirements.txt in its default working directory instead of your mylayer folder, hence the "No such file or directory" error.

Correct the command by splitting them with && to ensure the directory change happens before running Docker:

cd /c/Users/Myname/mylayer && docker run -v "$PWD":/var/task lambci/lambda:build-python3.8 /bin/sh -c "pip install -r requirements.txt -t python/lib/python3.8/site-packages/; exit"

Second, Account for Docker Toolbox Path Differences

Docker Toolbox on Windows 7 uses a VirtualBox virtual machine, which maps your Windows C:\Users directory to /c/Users inside the VM. You'll need to use Linux-style paths (forward slashes, case-sensitive) instead of Windows-style paths here.

For extra reliability, you can skip $PWD entirely and use an absolute path for the volume mount—this avoids any path resolution quirks in the Docker Toolbox terminal:

docker run -v "/c/Users/Myname/mylayer":/var/task lambci/lambda:build-python3.8 /bin/sh -c "pip install -r requirements.txt -t python/lib/python3.8/site-packages/; exit"

Third, Verify Your File & Folder Structure

Before re-running the command, double-check that your setup is correct:

  1. In the Docker Toolbox terminal, run this to confirm your files exist in the mapped directory:
    cd /c/Users/Myname/mylayer && ls
    
    You should see requirements.txt and your python/lib/python3.8/site-packages/ directory listed here.
  2. If you don't see the files, make sure requirements.txt is actually saved in C:\Users\Myname\mylayer on your Windows machine.
  3. If the directory structure is missing, re-create python/lib/python3.8/site-packages/ exactly as required—Docker needs this target folder to install dependencies into.

Troubleshooting Bonus: Enter the Container Interactively

If you're still stuck, run this command to enter the Docker container directly and inspect the files:

docker run -it -v "/c/Users/Myname/mylayer":/var/task lambci/lambda:build-python3.8 /bin/sh

Once inside, run ls /var/task to check if requirements.txt is present. If it's not, your volume mount path is incorrect—double-check the Windows-to-VM path mapping.

内容的提问来源于stack exchange,提问作者Alex M

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 15:57:28