Docker容器内运行aws-azure-login报错libnss3.so缺失求助
Docker容器中aws-azure-login启动失败:缺少Chromium依赖库
问题背景
我在远程服务器上常用以下命令执行aws-azure-login:
aws-azure-login -p profile_name --mode cli --no-prompt --force-refresh
主目录下的.aws/config文件包含多配置文件设置。现在需要在Docker容器中运行该工具,基于官方说明编写了Dockerfile并成功构建镜像,挂载本地.aws文件夹启动容器:
docker run -it --privileged --gpus all -v /home/username/.aws/:/root/.aws/ container_name
但容器内执行aws-azure-login时出现错误:
Using AWS SAML endpoint https://signin.aws.amazon.com/saml Error: Failed to launch the browser process! /usr/lib/node_modules/aws-azure-login/node_modules/puppeteer/.local-chromium/linux-982053/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
解决方案
错误根源是Puppeteer自带的Chromium缺少Ubuntu系统下的运行依赖库。libnss3.so是Chromium核心依赖之一,需要在Dockerfile中添加系统依赖安装步骤。
修改后的完整Dockerfile:
FROM nvidia/cuda:11.3.0-cudnn8-runtime-ubuntu20.04 ENV DEBIAN_FRONTEND=noninteractive RUN apt update --fix-missing && \ apt install python3-pip -y && \ # 安装Chromium必需的系统依赖库 apt install -y libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 \ libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2 libpango-1.0-0 libcairo2 && \ ln -sf /usr/bin/python3 /usr/bin/python && \ ln -sf /usr/bin/pip3 /usr/bin/pip RUN python -m pip install --upgrade pip # 安装Node.js、Puppeteer和aws-azure-login RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash - && apt-get install -y nodejs RUN npm --verbose i puppeteer RUN npm install -g --verbose aws-azure-login --unsafe-perm
关键说明
- 新增的
apt install命令安装了Ubuntu 20.04环境下运行Chromium的所有核心依赖,不仅解决libnss3缺失问题,还避免其他潜在的依赖报错 - 重新构建镜像并启动容器后,执行
aws-azure-login即可正常完成认证流程
内容的提问来源于stack exchange,提问作者Carlo
相关产品推荐
相关产品推荐

