簡體   English   中英

如何縮短 docker build-push-action 映像名稱

[英]How to shorten docker build-push-action image name

我正在使用docker/build-push-action並試圖找到一種方法來縮短圖像名稱,當它被推送到 github 注冊表時。

目前 docker 圖像名稱顯示為

ghcr.io/organization-name/project-image:latest

可以將其縮短為沒有ghcr.io/organization-name/的圖像名稱和標簽

The name of a docker image tag needs to include a registry hostname when you use docker push (unless you are pushing to the default Docker's public registry located at registry-1.docker.io )

這就是docker push知道要推送到哪里的方式。

這就是為什么典型的“構建和推送”步驟如下所示:

name: Build and Push Docker container

on:
  push:
    branches:
      - main

jobs:
  build-and-push:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1

    - name: Build the Docker image
      run: docker build -t ghcr.io/<<ACCOUNT NAME>>/<<IMAGE NAME>>:<<VERSION>> .

    - name: Setup GitHub Container Registry
      run: echo "$" | docker login https://ghcr.io -u $ --password-stdin

    - name: push to GitHub Container Registry
      run:  docker push ghcr.io/<<ACCOUNT NAME>>/<<IMAGE NAME>>:<<VERSION>>

在您的情況下,(使用docker/build-push-action ),即使您要使用本地注冊表,您仍然需要相應地標記。

-
        name: Build and push to local registry
        uses: docker/build-push-action@v3
        with:
          context: .
          push: true
          tags: localhost:5000/name/app:latest
                ^^^^^^^^^^^^^^
                # still a long tag name

只需在tags參數中指定,例如:

      - name: Build and push
        uses: docker/build-push-action@v3
        with:
          push: true
          tags: project-image:latest

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM