Docker 使用 github 构建和推送:无效的引用格式
Docker build and push using github: invalid reference format
我想构建我的镜像并将其推送到 dockerhub 使用 github actions.This is my repo
这就是我想要的工作方式:
name: ci
on:
push:
branches:
- 'master'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
load: true
tags: shirzadi/ehsan:latest
-
name: Push it!
run: docker push ${{ env.IMAGE }}:${{ env.GIT_SHA }}
这是结果:
您没有 env.IMAGE 数据。下面的一段代码应该可以完成这项工作。
- name: Build and push
run: docker build -t ${{ env.IMAGE }}:${{ github.sha }} .
env:
IMAGE: shirzadi/ehsan
- name: Push it!
run: docker push ${{ env.IMAGE }}:${{ github.sha }}
env:
IMAGE: shirzadi/ehsan
您正在使用不存在的环境变量。根据 docker/build-push-action@v2 文档,它可以一步构建、标记和推送您的图像:
jobs:
docker:
steps:
# ...
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: shirzadi/ehsan:latest,shirzadi/ehsan:${{ env.GITHUB_SHA }}
The tags
key lists 2 tags and use the GITHUB_SHA
environment variable. These tags will be pushed as the push
key is set to true.
参见:
我想构建我的镜像并将其推送到 dockerhub 使用 github actions.This is my repo
这就是我想要的工作方式:
name: ci
on:
push:
branches:
- 'master'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
load: true
tags: shirzadi/ehsan:latest
-
name: Push it!
run: docker push ${{ env.IMAGE }}:${{ env.GIT_SHA }}
这是结果:
您没有 env.IMAGE 数据。下面的一段代码应该可以完成这项工作。
- name: Build and push
run: docker build -t ${{ env.IMAGE }}:${{ github.sha }} .
env:
IMAGE: shirzadi/ehsan
- name: Push it!
run: docker push ${{ env.IMAGE }}:${{ github.sha }}
env:
IMAGE: shirzadi/ehsan
您正在使用不存在的环境变量。根据 docker/build-push-action@v2 文档,它可以一步构建、标记和推送您的图像:
jobs:
docker:
steps:
# ...
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: shirzadi/ehsan:latest,shirzadi/ehsan:${{ env.GITHUB_SHA }}
The
tags
key lists 2 tags and use theGITHUB_SHA
environment variable. These tags will be pushed as thepush
key is set to true.
参见: