Start here. This is the direct spoken answer to practice first.
Why this question matters
A container image becomes the deployable application boundary. Build choices affect repeatability, startup, patching, diagnostics, and the permissions an attacker receives if the process is compromised.
I would use a multi-stage build: restore, build, test, and publish with an SDK image, then copy only the published output into the matching ASP.NET Core runtime image. The final image would run as a non-root user, contain no source code or secrets, and receive environment-specific configuration at runtime. I would tag it with the commit or release identity and deploy that immutable image through every environment. A .dockerignore would keep build output, repository metadata, and local secrets out of the build context.