我正在尝试执行登录 AWS 的 bash,它会构建、标记并推送 docker 映像,这是我的 bash 文件内容:
aws ecr get-login-password --region us-east-2 --profile weather_ecr_agent | docker login --username AWS --password-stdin <LOGIN>
docker build -f ./Dockerfile -t cloud-weather-temperature: latest .
docker tag cloud-weather-temperature: latest <LOGIN>/cloud-weather-temperature: latest
docker push <LOGIN>/cloud-weather-temperature:latest
每当我尝试使用以下 cmd 在 CLI 上执行 bash 文件时: bash build_and_push_ecr_image.sh
我收到以下错误:
build_and_push_ecr_image.sh: /mnt/c/Users/USER/AppData/Local/Programs/Python/Python39/Scripts/aws: C:\Users\USER\AppData\Local\Programs\Python\Python39\python.exe: bad interpreter: No such file or directory
Error: Cannot perform an interactive login from a non TTY device
ERROR: "docker buildx build" requires exactly 1 argument.
See 'docker buildx build --help'.
Usage: docker buildx build [OPTIONS] PATH | URL | -
Start a build
"docker tag" requires exactly 2 arguments.
See 'docker tag --help'.
Usage: docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
invalid reference format
注意:AWSCLI 使用 pip 安装
aws-cli/1.34.22 Python/3.9.7 Windows/10 botocore/1.35.22
从你的文字中
aws-cli/1.34.22 Python/3.9.7 Windows/10 botocore/1.35.22
我认为你正在尝试在Windows上运行bash。你用的是什么bash?当您在终端上输入 wsl --version
时,您会看到什么?您安装了WSL吗?
您可以尝试安装它并在其中安装一个linux发行版。如果您想要更简单的方法并且只想让事情真正快速地工作,只需使用 Windows 等效的登录方法即可。您可以在AWS控制台上找到它们,打开ECR,单击您创建的图像,单击
View push commands
,切换Windows部分。
看起来有点像
(Get-ECRLoginCommand).Password | docker login --username AWS --password-stdin XXXXXXXXXXXX.xxx.ecr.eu-west-1.amazonaws.com
其余docker命令相同。
然后您将需要创建一个 powershell 脚本而不是 bash 脚本。