|
| 1 | +# Customizing your container |
| 2 | + |
| 3 | +You can control many aspects of the generated container through MSBuild properties. In general, if you could use a command in a Dockerfile to set some configuration, you can do the same via MSBuild. |
| 4 | + |
| 5 | +> **Note** |
| 6 | +> The only exception to this is `RUN` commands - due to the way we build containers, those cannot be emulated. If you need this functionality, you will need to use a Dockerfile to build your container images. |
| 7 | +
|
| 8 | +> **Note** |
| 9 | +> This package only supports Linux containers in this version. |
| 10 | +
|
| 11 | +## ContainerBaseImage |
| 12 | + |
| 13 | +This property controls the image used as the basis for your image. By default, we will infer the following values for you based on the properties of your project: |
| 14 | + |
| 15 | +* if your project is self-contained, we use the `mcr.microsoft.com/dotnet/runtime-deps` image as the base image |
| 16 | +* if your project is an ASP.NET Core project, we use the `mcr.microsoft.com/dotnet/aspnet` image as the base image |
| 17 | +* otherwise we use the `mcr.microsoft.com/dotnet/runtime` image as the base image |
| 18 | + |
| 19 | +We infer the tag of the image to be the numeric component of your chosen `TargetFramework` - so a `.net6.0` project will use the `6.0` tag of the inferred base image, a `.net7.0-linux` project will use the `7.0` tag, and so on. |
| 20 | + |
| 21 | +If you set a value here, you should set the fully-qualified name of the image to use as the base, including any tag you prefer: |
| 22 | + |
| 23 | +```xml |
| 24 | +<ContainerBaseImage>mcr.microsoft.com/dotnet/runtime:6.0</ContainerBaseImage> |
| 25 | +``` |
| 26 | + |
| 27 | +## ContainerRegistry |
| 28 | + |
| 29 | +This property controls the destination registry - the place that the newly-created image will be pushed to. |
| 30 | + |
| 31 | +Be default, we push to the local Docker daemon (annotated by `docker://`), but for this release you can specify any _unauthenticated_ registry. For example: |
| 32 | + |
| 33 | +```xml |
| 34 | +<ContainerRegistry>registry.mycorp.com:1234</ContainerRegistry> |
| 35 | +``` |
| 36 | + |
| 37 | +> **Note** |
| 38 | +> There is no authentication currently supported - that [will come in a future release](https://github.com/rainersigwald/containers/issues/70) - so make sure you're pointing to an unauthenticated registry |
| 39 | +
|
| 40 | +## ContainerImageName |
| 41 | + |
| 42 | +This property controls the name of the image itself, e.g `dotnet/runtime` or `my-awesome-app`. |
| 43 | + |
| 44 | +By default, the value used will be the `AssemblyName` of the project. |
| 45 | + |
| 46 | + |
| 47 | +```xml |
| 48 | +<ContainerImageName>my-super-awesome-app</ContainerImageName> |
| 49 | +``` |
| 50 | + |
| 51 | +> **Note** |
| 52 | +> Image names can only contain lowercase alphanumeric characters, periods, underscores, and dashes, and must start with a letter or number - any other characters will result in an error being thrown. |
| 53 | +
|
| 54 | +## ContainerImageTag |
| 55 | + |
| 56 | +This property controls the tag that is generated for the image. Tags are often used to refer to different versions of an application, but they can also refer to different operating system distributions, or even just different baked-in configuration. |
| 57 | + |
| 58 | +By default, the value used will be the `Version` of the project. |
| 59 | + |
| 60 | +```xml |
| 61 | +<ContainerImageTag>1.2.3-alpha2</ContainerImageTag> |
| 62 | +``` |
| 63 | + |
| 64 | +> **Note** |
| 65 | +> Tags can only contain up to 127 alphanumeric characters, periods, underscores, and dashes. They must start with an alphanumeric character or an underscore. Any other form will result in an error being thrown. |
| 66 | +
|
| 67 | +## ContainerWorkingDirectory |
| 68 | + |
| 69 | +This property controls the working directory of the container - the directory that commands are executed within if not other command is run. |
| 70 | + |
| 71 | +By default, we use the `/app` directory as the working directory. |
| 72 | + |
| 73 | +```xml |
| 74 | +<ContainerWorkingDirectory>/bin</ContainerWorkingDirectory> |
| 75 | +``` |
| 76 | + |
| 77 | +## Unsupported properties |
| 78 | + |
| 79 | +There are many other properties and items that we want to add support for in subsequent previews: |
| 80 | + |
| 81 | +* Entrypoints |
| 82 | +* Entrypoint Arguments |
| 83 | +* Ports |
| 84 | +* Environment Variables |
| 85 | +* Labels |
| 86 | + |
| 87 | +We expect to add them in future versions, so watch this space! |
0 commit comments