Skip to content

Commit 9028af1

Browse files
authored
Merge pull request #28226 from saschagrunert/image-config-json
Add docs about auth differences between Docker and Kubernetes
2 parents 1afb876 + c86b8a3 commit 9028af1

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

content/en/docs/concepts/containers/images.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,73 @@ template needs to include the `.docker/config.json` or mount a drive that contai
265265
All pods will have read access to images in any private registry once private
266266
registry keys are added to the `.docker/config.json`.
267267

268+
### Interpretation of config.json {#config-json}
269+
270+
The interpretation of `config.json` varies between the original Docker
271+
implementation and the Kubernetes interpretation. In Docker, the `auths` keys
272+
can only specify root URLs, whereas Kubernetes allows glob URLs as well as
273+
prefix-matched paths. This means that a `config.json` like this is valid:
274+
275+
```json
276+
{
277+
"auths": {
278+
"*my-registry.io/images": {
279+
"auth": ""
280+
}
281+
}
282+
}
283+
```
284+
285+
The root URL (`*my-registry.io`) is matched by using the following syntax:
286+
287+
```
288+
pattern:
289+
{ term }
290+
291+
term:
292+
'*' matches any sequence of non-Separator characters
293+
'?' matches any single non-Separator character
294+
'[' [ '^' ] { character-range } ']'
295+
character class (must be non-empty)
296+
c matches character c (c != '*', '?', '\\', '[')
297+
'\\' c matches character c
298+
299+
character-range:
300+
c matches character c (c != '\\', '-', ']')
301+
'\\' c matches character c
302+
lo '-' hi matches character c for lo <= c <= hi
303+
```
304+
305+
Image pull operations would now pass the credentials to the CRI container
306+
runtime for every valid pattern. For example the following container image names
307+
would match successfully:
308+
309+
- `my-registry.io/images`
310+
- `my-registry.io/images/my-image`
311+
- `my-registry.io/images/another-image`
312+
- `sub.my-registry.io/images/my-image`
313+
- `a.sub.my-registry.io/images/my-image`
314+
315+
The kubelet performs image pulls sequentially for every found credential. This
316+
means, that multiple entries in `config.json` are possible, too:
317+
318+
```json
319+
{
320+
"auths": {
321+
"my-registry.io/images": {
322+
"auth": ""
323+
},
324+
"my-registry.io/images/subpath": {
325+
"auth": ""
326+
}
327+
}
328+
}
329+
```
330+
331+
If now a container specifies an image `my-registry.io/images/subpath/my-image`
332+
to be pulled, then the kubelet will try to download them from both
333+
authentication sources if one of them fails.
334+
268335
### Pre-pulled images
269336

270337
{{< note >}}
@@ -390,3 +457,4 @@ Kubelet will merge any `imagePullSecrets` into a single virtual `.docker/config.
390457

391458
* Read the [OCI Image Manifest Specification](https://github.com/opencontainers/image-spec/blob/master/manifest.md).
392459
* Learn about [container image garbage collection](/docs/concepts/architecture/garbage-collection/#container-image-garbage-collection).
460+
* Learn more about [pulling an Image from a Private Registry](/docs/tasks/configure-pod-container/pull-image-private-registry).

content/en/docs/tasks/configure-pod-container/pull-image-private-registry.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ docker login
3535
When prompted, enter your Docker ID, and then the credential you want to use (access token,
3636
or the password for your Docker ID).
3737

38-
The login process creates or updates a `config.json` file that holds an authorization token.
38+
The login process creates or updates a `config.json` file that holds an authorization token. Review [how Kubernetes interprets this file](/docs/concepts/containers/images#config-json).
3939

4040
View the `config.json` file:
4141

0 commit comments

Comments
 (0)