dockerdocker-buildkit

How to specify where to push using docker buildx build command


I was reading the docs regarding docker buildx build to build to multiple architectures and I got puzzled with the --push option, it says that it pushes to the registry directly but how does it know or how can I specify where I want it to push the built images?

For more context, my plan is to push the images to my Gitlab private container registry from my Gitlab CI/CD pipeline


Solution

  • First login to your private registry, with the command docker login myregistry.com. After that specify your registry in the tag name of your image docker buildx build --push -t myregistry.com/appname:version . and it should push your image to myregistry.com after build.

    Note: Docker looks for either a “.” (domain separator) or “:” (port separator) to learn that the first part of the repository name is a location and not a user name.