我正在嘗試將我的 Docker 映像推送到 AWS ECR,并且我正在Not Authorized嘗試這樣做。
我將所有必需的變數設定為 Azure DevOps 中的變數,這就是我正在使用的。所以我不確定為什么它沒有得到正確的身份驗證。
這是我的 YAML 代碼:
trigger:
- main
pool:
vmImage: ubuntu-latest
strategy:
matrix:
Python38:
python.version: '3.8'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'
- script: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip requests os smtplib datetime
pip install -r requirements.txt
displayName: 'Install dependencies'
- task: CopyFiles@2
inputs:
SourceFolder:
Contents: '*'
TargetFolder: $(build.artifactstagingdirectory)
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(build.artifactstagingdirectory)'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/project.zip'
replaceExistingArchive: true
- task: S3Upload@1
inputs:
awsCredentials: 'weather'
regionName: 'us-west-2'
bucketName: 'weather-update-project-bucket'
sourceFolder: '$(build.artifactstagingdirectory)'
globExpressions: '*project.zip*'
targetFolder: 'python'
createBucket: true
- script: |
aws ecr get-login-password --region $(AWS_REGION) | docker login --username AWS --password-stdin $(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com
displayName: 'Login to AWS'
env:
AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
- task: Docker@2
inputs:
repository: 'public.ecr.aws/u1c1h9j4/weather-update-project'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
tags: 'latest'
uj5u.com熱心網友回復:
最好使用Amazon ECR 推送任務而不是常規 Docker 推送。
首先,使用以下命令構建映像Docker@2:
- task: Docker@2
displayName: Build an image
inputs:
command: build
dockerfile: '**/Dockerfile'
buildContext: '$(Build.SourcesDirectory)'
tags: 'latest'
之后,推動ECRPushImage@1:
- task: ECRPushImage@1
inputs:
awsCredentials: 'weather'
regionName: us-west-2
imageSource: 'imagename'
sourceImageName: 'YOUR-IAMGE-NAME'
sourceImageTag: 'latest'
pushTag: 'latest'
repositoryName: 'YOUR-AWS-ECR-REPO'
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/431307.html
標籤:亚马逊网络服务 码头工人 天蓝色的devops 天蓝色管道 亚马逊-ecr
下一篇:記憶遞回呼叫時的巨大效率差異
