如何解决lambci/lambda:python3.6容器中无su/sudo却需root权限的安装困境
How to Install Packages with Yum in lambci/lambda:python3.6 Without Sudo/Su
Got it, let's break this down. The lambci/lambda:python3.6 image runs as the non-root lambda user by default—this is to mimic the actual AWS Lambda execution environment, which is why you don't have sudo or su available, and yum install throws a permission error.
Here's the straightforward fix to get root access and use yum:
- Start the container as the root user directly
Run this command instead of your original one:
Adding thedocker run -v "$PWD":/var/task --user root --entrypoint bash -it lambci/lambda:python3.6--user rootflag launches the container with full root privileges right away. Once you're in the interactive shell, you can runyum install <package-name>without any permission issues—no need for sudo or su at all.
A quick note: While running as root deviates from the default Lambda runtime setup, it's the only practical way to install system-level packages in this image when you need them for testing or development.
内容的提问来源于stack exchange,提问作者Hello lad
相关产品推荐
相关产品推荐

