You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
document all remaining items and properties, as well as auth (#201)
* document all remaining items and properties
* Add first docs on registry auth
* add note to getting started about console apps
* Update docs/ContainerCustomization.md
Copy file name to clipboardExpand all lines: docs/ContainerCustomization.md
+78-10Lines changed: 78 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Customizing your container
2
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.
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
4
5
5
> **Note**
6
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.
@@ -39,11 +39,10 @@ Be default, we push to the local Docker daemon (annotated by `docker://`), but f
39
39
40
40
## ContainerImageName
41
41
42
-
This property controls the name of the image itself, e.g `dotnet/runtime` or `my-awesome-app`.
42
+
This property controls the name of the image itself, e.g `dotnet/runtime` or `my-awesome-app`.
43
43
44
44
By default, the value used will be the `AssemblyName` of the project.
> 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.
71
69
@@ -84,6 +82,7 @@ By default, we use the `/app` directory as the working directory.
84
82
This item adds TCP or UDP ports to the list of known ports for the container. This enables container runtimes like Docker to map these ports to the host machine automatically. This is often used as documentation for the container, but can also be used to enable automatic port mapping.
85
83
86
84
ContainerPort items have two properties:
85
+
87
86
* Include
88
87
* The port number to expose
89
88
* Type
@@ -103,23 +102,92 @@ ContainerPort items have two properties:
103
102
This item adds a metadata label to the container. Labels have no impact on the container at runtime, but are often used to store version and authoring metadata for use by security scanners and other infrastructure tools.
104
103
105
104
ContainerLabel items have two properties:
105
+
106
106
* Include
107
107
* The key of the label
108
108
* Value
109
109
* The value of the label - this may be empty
110
110
111
+
See [default container labels](#default-container-labels) for a list of labels that are created by default.
This item adds a new environment variable to the container. Environment variables will be accessible to the application running in the container immediately, and are often used to change the runtime behavior of the running application.
122
+
123
+
ContainerEnvironmentVariable items have two properties:
This item can be used to customize the entrypoint of the container - the binary that is run by default when the container is started.
139
+
140
+
By default, for builds that create an executable binary that binary is set as the ContainerEntrypoint. For builds that do not create an executable binary `dotnet path/to/application.dll` is used as the ContainerEntrypoint.
141
+
142
+
ContainerEntrypoint items have one property:
143
+
144
+
* Include
145
+
* The command, option, or argument to use in the entrypoint command
146
+
147
+
```xml
148
+
<ItemGroupLabel="Entrypoint Assignment">
149
+
<!-- This is how you would start the dotnet ef tool in your container -->
150
+
<ContainerEntrypointInclude="dotnet" />
151
+
<ContainerEntrypointInclude="ef" />
152
+
153
+
<!-- This shorthand syntax means the same thing - note the semicolon separating the tokens. -->
154
+
<ContainerEntrypointInclude="dotnet;ef" />
155
+
</ItemGroup>
156
+
```
157
+
158
+
## ContainerEntrypointArgs
159
+
160
+
This item controls the default arguments provided to the `ContainerEntrypoint`. This should be used when the ContainerEntrypoint is a program that the user might want to use on its own.
161
+
162
+
By default, no ContainerEntrypointArgs are created on your behalf.
163
+
164
+
ContainerEntrypointArg items have one property:
165
+
166
+
* Include
167
+
* The option or argument to apply to the ContainerEntrypoint command
168
+
169
+
```xml
170
+
<ItemGroup>
171
+
<!-- Assuming the ContainerEntrypoint defined above, this would be the way to update the database by default, but let the user run a different EF command. -->
172
+
<ContainerEntrypointArgsInclude="database" />
173
+
<ContainerEntrypointArgsInclude="update" />
174
+
175
+
<!-- This is the shorthand syntax for the same idea -->
ASP.NET Core applications have certain defaults that are set to make containers more 'plug and play'.
183
+
184
+
* A ContainerPort item is set to expose TCP port 80
185
+
* The ASPNETCORE_URLS environment variable is set to `http://+:80` to match that port value.
186
+
187
+
Both of these will be skipped if a custom value is set.
118
188
119
-
There are many other properties and items that we want to add support for in subsequent previews:
189
+
## Default container labels
120
190
121
-
* Entrypoints
122
-
* Entrypoint Arguments
123
-
* Environment Variables
191
+
Labels are often used to provide consistent metadata on container images. This package provides some default labels to encourage better maintainability of the generated images.
124
192
125
-
We expect to add them in future versions, so watch this space!
193
+
*`org.opencontainers.image.created` is set to the ISO 8601 format of the current UTC DateTime
Copy file name to clipboardExpand all lines: docs/GettingStarted.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,4 +25,4 @@ For more information, see [Customizing a container](./ContainerCustomization.md)
25
25
> This package only supports Linux containers in this version.
26
26
27
27
> **Note**
28
-
> This package only supports Web projects (those that use the `Microsoft.NET.Sdk.Web` SDK) in this version.
28
+
> If you are publishing a console application (or any non-Web project) you will need to add the `/t:PublishContainer` option to the command line above. See [dotnet/sdk-container-builds#141](https://github.com/dotnet/sdk-container-builds/issues/141) for more details.
Interacting with private container registries requires authenticating with those registries.
4
+
5
+
Docker has established a pattern with this via the [`docker login`](https://docs.docker.com/engine/reference/commandline/login/) command, which is a way of interacting with a Docker config file that contains rules for authenticating with specific registries. This file, and the authentication types it encodes, are supported by Microsoft.Net.Build.Containers for registry authentication. This should ensure that this package works seamlessly with any registry you can `docker pull` from and `docker push`.
6
+
7
+
## Kinds of authentication
8
+
9
+
The config.json file contains three kinds of authentication:
10
+
11
+
* explicit username/password
12
+
* credential helpers
13
+
* system keychain
14
+
15
+
### Explicit username/password
16
+
17
+
The `auths` section of the config.json file is a key/value map between registry names and Base64-encoded username:password strings. In a 'default' Docker scenario, running `docker login <registry> -u <username> -p <password>` will create new items in this map. These kinds of credentials are popular in Continuous Integration systems, where logging in is done by tokens at the start of a run, but are less popular for end-user development machines, where having bare credentials in a file is a security risk.
18
+
19
+
### Credential helpers
20
+
21
+
The `credHelpers` section of the config.json file is a key/value map between registry names and the names of specific programs that can be used to create and retrieve credentials for that registry. This is often used when particular registries have complex authentication requirements. In order for this kind of authentication to work, you must have an application named `docker-credential-{name}` on your system's PATH. These kinds of credentials tend to be very secure, but can be hard to setup on development or CI machines.
22
+
23
+
### System Keychains
24
+
25
+
The `credsStore` section is a single string property whose value is the name of a docker credential helper program that knows how to interface with the system's password manager. For Windows this might be `wincred` for example. These are very popular with Docker installers for MacOS and Windows.
26
+
27
+
## Known-supported registries
28
+
29
+
All of the above mechanisms are supported by this package. When we push or pull from a registry we will incorporate these credential helpers and invoke them to get any necessary credentials the registry asks for.
30
+
31
+
The following registries have been explicitly tested:
32
+
33
+
* Azure Container Registry*
34
+
* AWS Elastic Container Registry
35
+
* GitHub Package Registry
36
+
* GitLab Container Registry
37
+
* Google Cloud Artifact Registry
38
+
* Quay.io
39
+
40
+
## Known-unsupported registries
41
+
42
+
* Docker Hub
43
+
44
+
## Notes for specific registries
45
+
46
+
### Azure Container Registry
47
+
48
+
When authenticating to an Azure Container Registry, at this moment only authentication with an admin username and password is supported. This is the same as running `az acr login -n <registry> -u <username> -p <password>`. Token-based login, like `az acr login -n <registry>` is not supported yet.
0 commit comments