How to manage multiple dockerfiles in a single .NET project?

Viewed 80

If .NET SDK and ASP.NET supports different platforms in Docker, and you want to support several of these platforms(if not all), I figured you need to have different dockerfiles for each platform per project. But how should you manage that in your projects? And how can you publish all of those dockerfiles to the registry faster with ease?

1 Answers

You usually have one Dockerfile and with the use of docker buildx, you can then use --platform parameter to build and pack image for multiple platforms. I found a nice guide. When you use this approach you then push one image, and on DockerHub you then get multiple "tags", one for each platform.

You can then also use the --platform parameter running the docker image with docker run command and you can put in wanted platform and it will try to pull and run the image with that platform.

We only use these for simple multi arch base images, without any complex logic or installs of any "specific" packages. I have talked with few friends of a different company where they are using more "intensive" tasks. They still have one docker image and have platform/arch checks inside the Dockerfile to execute commands per architecture instead of manually managing multiple files.

Related