Skip to content

Conversation

@rumpl
Copy link
Member

@rumpl rumpl commented Jan 11, 2023

- What I did

Implemented docker run with the containerd store.

Upstreams:

I added the second and third commit because parts of the code changes are needed for run to work.

- How I did it

Mostly avoiding doing anything with layers if containerd is used as an image store and using snapshots instead. Some tweaks were also needed in the way we create the OCI spec for the container.

- How to verify it

Run:

$ docker run hello-world
$ docker run busybox arch
$ docker run --platform linux/arm64 arch
$ docker run --platform linux/amd64 arch
$ docker run -it docker/doodle

All of these should work after #44756 is merged.

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)


// Containerd related methods

ResolveDescriptor(ctx context.Context, refOrID string) (ocispec.Descriptor, error)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my fork we had an interface that we would use only in the case we use the containerd store but that sucked.

I realise this isn't ideal, having an interface that does too much and having one of the implementors panic...

I considered moving some of the things over to the libcontainerd but I'm not sure it would help and also I'm not really a fan of that wrapper.

Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is also that this interface will be more and more c8d specific as we move along with the migration.

@rumpl rumpl added containerd-integration Issues and PRs related to containerd integration area/runtime Runtime labels Jan 11, 2023
@rumpl rumpl force-pushed the containerd-run branch 2 times, most recently from 1a6ea5c to 6b05652 Compare January 12, 2023 08:56
@rumpl
Copy link
Member Author

rumpl commented Jan 12, 2023

The failure is unrelated

#37 40.56 E: Failed to fetch http://cdn-fastly.deb.debian.org/debian/pool/main/g/gcc-10-cross/gcc-10-arm-linux-gnueabi-base_10.2.1-6cross1_amd64.deb  Error reading from server - read (104: Connection reset by peer) [IP: 146.75.30.132 80]
#37 40.56 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Copy link
Contributor

@vvoland vvoland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +173 to 184
if daemon.UsesSnapshotter() {
if err := daemon.imageService.PrepareSnapshot(ctx, ctr.ID, opts.params.Config.Image, opts.params.Platform); err != nil {
return nil, err
}
} else {
// Set RWLayer for container after mount labels have been set
rwLayer, err := daemon.imageService.CreateLayer(ctr, setupInitLayer(daemon.idMapping))
if err != nil {
return nil, errdefs.System(err)
}
ctr.RWLayer = rwLayer
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈
I think it's fine for now, just to get things working, but we definitely should look into refactoring the RWLayer into an implementation detail of the graphdriver's ImageService implementation, so that we could just drop the hacky if daemon.UsesSnapshotter to just rely on different interface implementation.

The RWLayer is all over the place which makes this a lot of work, so I think it's reasonable to just go with this one for now.

Copy link
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems OK to me, although my knowledge of these codepaths is admittedly very limited. 🙈

@rumpl rumpl force-pushed the containerd-run branch 2 times, most recently from 627dabc to 312db91 Compare February 6, 2023 15:41
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

As discussed on slack; last change went in the wrong commit, and probably ok to squash all commits

@thaJeztah
Copy link
Member

doh!

Looks like something needs to be fixed up;

#23 55.02 daemon/containerd/mount.go:24:2: tempMountLocation declared but not used
#23 55.02 daemon/containerd/mount.go:26:28: undefined: tempDir

@rumpl
Copy link
Member Author

rumpl commented Feb 6, 2023

doh!

Looks like something needs to be fixed up;

#23 55.02 daemon/containerd/mount.go:24:2: tempMountLocation declared but not used
#23 55.02 daemon/containerd/mount.go:26:28: undefined: tempDir

Oop, will fix!

@rumpl
Copy link
Member Author

rumpl commented Feb 6, 2023

Hm... Some of the checks fail because of fatal: detected dubious ownership in repository at '/go/src/github.com/docker/docker', not sure what is going on

@thaJeztah
Copy link
Member

@rumpl see #44930

Signed-off-by: Djordje Lukic <[email protected]>

c8d/daemon: Mount root and fill BaseFS

This fixes things that were broken due to nil BaseFS like `docker cp`
and running a container with workdir override.

This is more of a temporary hack than a real solution.
The correct fix would be to refactor the code to make BaseFS and LayerRW
an implementation detail of the old image store implementation and use
the temporary mounts for the c8d implementation instead.
That requires more work though.

Signed-off-by: Paweł Gronowski <[email protected]>

daemon/images: Don't unset BaseFS

Signed-off-by: Paweł Gronowski <[email protected]>
Copy link
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM 👍

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; it's green!

@thaJeztah thaJeztah merged commit c132f42 into moby:master Feb 7, 2023
@thaJeztah thaJeztah added this to the v-next milestone Feb 7, 2023
@rumpl rumpl deleted the containerd-run branch February 7, 2023 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/runtime Runtime containerd-integration Issues and PRs related to containerd integration status/4-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants