https://github.com/kevinpollet/go-docker-multi-arch
The purpose of this repository is to show how to build a multi-arch Docker image for amd64 and arm64
https://github.com/kevinpollet/go-docker-multi-arch
docker golang multiarch
Last synced: 8 months ago
JSON representation
The purpose of this repository is to show how to build a multi-arch Docker image for amd64 and arm64
- Host: GitHub
- URL: https://github.com/kevinpollet/go-docker-multi-arch
- Owner: kevinpollet
- License: mit
- Created: 2022-07-06T16:10:25.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-08T19:26:55.000Z (over 3 years ago)
- Last Synced: 2025-03-18T05:16:19.952Z (12 months ago)
- Topics: docker, golang, multiarch
- Language: Dockerfile
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-docker-multi-arch
The purpose of this repository is to show how to build a multi-arch Docker image from the command-line for `amd64`
and `arm64` architectures. The Go application built inside the Docker image displays the OS, Architecture and Go version
of the runtime environment.
The [buildx](https://docs.docker.com/buildx/working-with-buildx/#build-multi-platform-images) plugin allows to build and
push multi-platform images from the command-line. The following command will create and use
a `buildx` [builder instance](https://docs.docker.com/buildx/working-with-buildx/#work-with-builder-instances):
```shell
$ docker buildx create --name multi-arch --use
```
Build and push the multi-arch Docker image with:
```shell
$ docker buildx build --platform=linux/amd64,linux/arm64 -t /go-docker-multi-arch --push .
```
Using both images on Apple Silicon will output the following:
```shell
$ docker run --rm /go-docker-multi-arch
OS/Arch: linux/arm64
Go version: go1.17.11
$ docker run --platform linux/amd64 --rm /go-docker-multi-arch
OS/Arch: linux/amd64
Go version: go1.17.11
```
## License
[MIT](./LICENSE)