mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
daemon: Fix panic on Windows when restoring pre v28 container
The container platform migration tries to deduce the platform data from
the containerd content store if it's available.
However, on Windows we currently default to a non-containerd runtime
setup, so the containerd client is nil and accessing its content store
paniced:
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x11b48e4]
goroutine 87 [running]:
github.com/containerd/containerd/v2/client.(*Client).ContentStore(0xc0003a0008?)
/go/src/github.com/docker/docker/vendor/github.com/containerd/containerd/v2/client/client.go:645 +0x24
github.com/docker/docker/daemon.(*Daemon).load(0xc00026e488, {0xc000c13d40, 0x40})
/go/src/github.com/docker/docker/daemon/container.go:84 +0x289
github.com/docker/docker/daemon.(*Daemon).restore.func1({0xc000c13d40, 0x40})
/go/src/github.com/docker/docker/daemon/daemon.go:236 +0x207
created by github.com/docker/docker/daemon.(*Daemon).restore in goroutine 1
/go/src/github.com/docker/docker/daemon/daemon.go:229 +0x1a7
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x11b48e4]
goroutine 90 [running]:
github.com/containerd/containerd/v2/client.(*Client).ContentStore(0xc000313608?)
/go/src/github.com/docker/docker/vendor/github.com/containerd/containerd/v2/client/client.go:645 +0x24
github.com/docker/docker/daemon.(*Daemon).load(0xc00026e488, {0xc000c13e00, 0x40})
/go/src/github.com/docker/docker/daemon/container.go:84 +0x289
github.com/docker/docker/daemon.(*Daemon).restore.func1({0xc000c13e00, 0x40})
/go/src/github.com/docker/docker/daemon/daemon.go:236 +0x207
created by github.com/docker/docker/daemon.(*Daemon).restore in goroutine 1
/go/src/github.com/docker/docker/daemon/daemon.go:229 +0x1a7
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x11b48e4]
```
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -81,7 +81,9 @@ func (daemon *Daemon) load(id string) (*container.Container, error) {
|
||||
if ctr.ImagePlatform.Architecture == "" {
|
||||
migration := daemonPlatformReader{
|
||||
imageService: daemon.imageService,
|
||||
content: daemon.containerdClient.ContentStore(),
|
||||
}
|
||||
if daemon.containerdClient != nil {
|
||||
migration.content = daemon.containerdClient.ContentStore()
|
||||
}
|
||||
migrateContainerOS(context.TODO(), migration, ctr)
|
||||
}
|
||||
|
||||
@@ -104,6 +104,9 @@ func (r daemonPlatformReader) ReadPlatformFromConfigByImageManifest(
|
||||
ctx context.Context,
|
||||
desc ocispec.Descriptor,
|
||||
) (ocispec.Platform, error) {
|
||||
if r.content == nil {
|
||||
return ocispec.Platform{}, errors.New("not an containerd image store")
|
||||
}
|
||||
b, err := content.ReadBlob(ctx, r.content, desc)
|
||||
if err != nil {
|
||||
return ocispec.Platform{}, err
|
||||
|
||||
Reference in New Issue
Block a user