github.com/goreleaser/goreleaser@v1.25.1/www/docs/customization/docker_manifest.md (about)

     1  # Docker Manifests
     2  
     3  GoReleaser can also create and push Docker multi-platform images using the
     4  `docker manifest` tool.
     5  
     6  For it to work, it needs to be enabled in the
     7  [client's configuration](https://github.com/docker/cli/blob/master/experimental/README.md).
     8  
     9  Please make sure `docker manifest` works before opening issues.
    10  
    11  Notice that if you have something in the `docker_manifests` section in your
    12  config file, GoReleaser will add the manifest's to the release notes instead of
    13  the Docker images names.
    14  
    15  !!! warning
    16      Notice that the images used in the manifest **need to be pushed** for this
    17      to work. This is a limitation of how `docker manifest create` works. For
    18      more info, check
    19      [this issue](https://github.com/goreleaser/goreleaser/issues/2606).
    20  
    21  ## Customization
    22  
    23  You can create several manifests in a single GoReleaser run, here are all the
    24  options available:
    25  
    26  ```yaml
    27  # .goreleaser.yaml
    28  docker_manifests:
    29    # You can have multiple Docker manifests.
    30  -
    31    # ID of the manifest, needed if you want to filter by it later on (e.g. on
    32    # custom publishers).
    33    id: myimg
    34  
    35    # Name for the manifest.
    36    #
    37    # Templates: allowed
    38    name_template: "foo/bar:{{ .Version }}"
    39  
    40    # Image name to be added to this manifest.
    41    #
    42    # Templates: allowed
    43    image_templates:
    44    - "foo/bar:{{ .Version }}-amd64"
    45    - "foo/bar:{{ .Version }}-arm64v8"
    46  
    47    # Extra flags to be passed down to the manifest create command.
    48    create_flags:
    49    - --insecure
    50  
    51    # Extra flags to be passed down to the manifest push command.
    52    push_flags:
    53    - --insecure
    54  
    55    # Skips the Docker manifest.
    56    # If you set this to `false` or `auto` on your source Docker configuration,
    57    #  you'll probably want to do the same here.
    58    #
    59    # If set to `auto`, the manifest will not be created in case there is an
    60    #  indicator of a prerelease in the tag, e.g. v1.0.0-rc1.
    61    #
    62    # Templates: allowed (since v1.19)
    63    skip_push: false
    64  
    65    # Set the "backend" for the Docker manifest pipe.
    66    # Valid options are: docker, podman
    67    #
    68    # Relevant notes:
    69    # 1. podman is a GoReleaser Pro feature and is only available on Linux;
    70    # 2. if you set podman here, the respective docker configuration need to use
    71    #     podman too.
    72    #
    73    # Default: 'docker'
    74    use: docker
    75  ```
    76  
    77  !!! tip
    78      Learn more about the [name template engine](/customization/templates/).
    79  
    80  ## How it works
    81  
    82  We basically build and push our images as usual, but we also add a new
    83  section to our configuration defining, which images are part of which manifests.
    84  
    85  GoReleaser will create and publish the manifest in its publishing phase.
    86  
    87  !!! warning
    88      Unfortunately, the manifest tool needs the images to be pushed to create
    89      the manifest, that's why we both create and push it in the publishing phase.
    90  
    91  ## Example config
    92  
    93  In this example we will use Docker's `--platform` option to specify the target platform.
    94  This way we can use the same `Dockerfile` for both the `amd64`, and the `arm64`
    95  images (and possibly others):
    96  
    97  ```dockerfile
    98  # Dockerfile
    99  FROM alpine
   100  ENTRYPOINT ["/usr/bin/mybin"]
   101  COPY mybin /usr/bin/mybin
   102  ```
   103  
   104  Then, on our GoReleaser configuration file, we need to define both the
   105  `dockers`, and the `docker_manifests` section:
   106  
   107  ```yaml
   108  # .goreleaser.yaml
   109  builds:
   110  - env:
   111    - CGO_ENABLED=0
   112    binary: mybin
   113    goos:
   114    - linux
   115    goarch:
   116    - amd64
   117    - arm64
   118  dockers:
   119  - image_templates:
   120    - "foo/bar:{{ .Version }}-amd64"
   121    use: buildx
   122    dockerfile: Dockerfile
   123    build_flag_templates:
   124    - "--platform=linux/amd64"
   125  - image_templates:
   126    - "foo/bar:{{ .Version }}-arm64v8"
   127    use: buildx
   128    goarch: arm64
   129    dockerfile: Dockerfile
   130    build_flag_templates:
   131    - "--platform=linux/arm64/v8"
   132  docker_manifests:
   133  - name_template: "foo/bar:{{ .Version }}"
   134    image_templates:
   135    - "foo/bar:{{ .Version }}-amd64"
   136    - "foo/bar:{{ .Version }}-arm64v8"
   137  ```
   138  
   139  !!! warning
   140      Notice that `--platform` needs to be in the Docker platform format, not Go's.
   141  
   142  That config will build the 2 Docker images defined, as well as the manifest,
   143  and push everything to Docker Hub.
   144  
   145  ## Podman
   146  
   147  !!! success "GoReleaser Pro"
   148      The podman backend is a [GoReleaser Pro feature](/pro/).
   149  
   150  You can use [`podman`](https://podman.io) instead of `docker` by setting `use`
   151  to `podman` on your configuration:
   152  
   153  ```yaml
   154  # .goreleaser.yaml
   155  docker_manifests:
   156  - name_template: "foo/bar:{{ .Version }}"
   157    image_templates:
   158    - "foo/bar:{{ .Version }}-amd64"
   159    - "foo/bar:{{ .Version }}-arm64v8"
   160    use: podman
   161  ```
   162  
   163  Note that GoReleaser will not install Podman for you, nor change any of its
   164  configuration.