Skip to content

Commit c86b8a3

Browse files
Add docs about auth differences between Docker and Kubernetes
The interpretation between Docker and Kubernetes varies when comparing its implementations. This allows different use cases and should be documented accordingly. Signed-off-by: Sascha Grunert <[email protected]> Co-authored-by: Geoffrey Cline <[email protected]> Signed-off-by: Sascha Grunert <[email protected]>
1 parent 5c84822 commit c86b8a3

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
@@ -208,6 +208,73 @@ template needs to include the `.docker/config.json` or mount a drive that contai
208208
All pods will have read access to images in any private registry once private
209209
registry keys are added to the `.docker/config.json`.
210210

211+
### Interpretation of config.json {#config-json}
212+
213+
The interpretation of `config.json` varies between the original Docker
214+
implementation and the Kubernetes interpretation. In Docker, the `auths` keys
215+
can only specify root URLs, whereas Kubernetes allows glob URLs as well as
216+
prefix-matched paths. This means that a `config.json` like this is valid:
217+
218+
```json
219+
{
220+
"auths": {
221+
"*my-registry.io/images": {
222+
"auth": ""
223+
}
224+
}
225+
}
226+
```
227+
228+
The root URL (`*my-registry.io`) is matched by using the following syntax:
229+
230+
```
231+
pattern:
232+
{ term }
233+
234+
term:
235+
'*' matches any sequence of non-Separator characters
236+
'?' matches any single non-Separator character
237+
'[' [ '^' ] { character-range } ']'
238+
character class (must be non-empty)
239+
c matches character c (c != '*', '?', '\\', '[')
240+
'\\' c matches character c
241+
242+
character-range:
243+
c matches character c (c != '\\', '-', ']')
244+
'\\' c matches character c
245+
lo '-' hi matches character c for lo <= c <= hi
246+
```
247+
248+
Image pull operations would now pass the credentials to the CRI container
249+
runtime for every valid pattern. For example the following container image names
250+
would match successfully:
251+
252+
- `my-registry.io/images`
253+
- `my-registry.io/images/my-image`
254+
- `my-registry.io/images/another-image`
255+
- `sub.my-registry.io/images/my-image`
256+
- `a.sub.my-registry.io/images/my-image`
257+
258+
The kubelet performs image pulls sequentially for every found credential. This
259+
means, that multiple entries in `config.json` are possible, too:
260+
261+
```json
262+
{
263+
"auths": {
264+
"my-registry.io/images": {
265+
"auth": ""
266+
},
267+
"my-registry.io/images/subpath": {
268+
"auth": ""
269+
}
270+
}
271+
}
272+
```
273+
274+
If now a container specifies an image `my-registry.io/images/subpath/my-image`
275+
to be pulled, then the kubelet will try to download them from both
276+
authentication sources if one of them fails.
277+
211278
### Pre-pulled images
212279

213280
{{< note >}}
@@ -332,3 +399,4 @@ Kubelet will merge any `imagePullSecrets` into a single virtual `.docker/config.
332399

333400
* Read the [OCI Image Manifest Specification](https://github.com/opencontainers/image-spec/blob/master/manifest.md).
334401
* Learn about [container image garbage collection](/docs/concepts/architecture/garbage-collection/#container-image-garbage-collection).
402+
* 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
@@ -28,7 +28,7 @@ docker login
2828

2929
When prompted, enter your Docker username and password.
3030

31-
The login process creates or updates a `config.json` file that holds an authorization token.
31+
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).
3232

3333
View the `config.json` file:
3434

0 commit comments

Comments
 (0)