-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add podman machine Containerfile #21251
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@baude @ashley-cui @cgwalters PTAL Once we have the design here approved, I can go and remove a lot of code from ignition.go that sets these up. @cgwalters I do question whether I should setup the config files in /usr/etc or /etc? |
RUN systemctl enable podman.service | ||
RUN printf "\nconfdir /etc/chrony.d\n" >> /etc/chrony.conf | ||
|
||
COPY 10-inotify-instances.conf /usr/etc/sysctl.d/10-inotify-instances.conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The preference here is is actually to use /usr/lib/sysctl.d
. This configuration is part of the OS.
Otherwise, use /etc
. Don't use /usr/etc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
COPY subuid /usr/etc/subgid | ||
COPY subuid /usr/etc/subuid | ||
RUN groupadd -g 501 core; useradd -u 501 -g 501 core | ||
RUN --mount=type=tmpfs,destination=/var ostree container commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be dropped currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped
COPY linger-example.service /home/core/.config/systemd/user/linger-example.service | ||
COPY containers-home.conf /home/core/.config/containers/containers.conf | ||
|
||
RUN mkdir -p /home/core/.config/systemd/user/default.target.wants; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I'd recommend instead of this is to write these files into /etc/skel
- and have the user created on firstboot via systemd-sysusers (per above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no support for /etc/subuid and /etc/subgid there though? Or just create those files and let systemd-sysusers create it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now using /etc/skel
COPY podman-docker.conf /usr/etc/tmpfiles.d/podman-docker.conf | ||
COPY subuid /usr/etc/subgid | ||
COPY subuid /usr/etc/subuid | ||
RUN groupadd -g 501 core; useradd -u 501 -g 501 core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is tricky...I know we're adding it for compatibility, but going forward I think it'd probably make sense to allocate a podman
user for example.
But even more importantly it will work better if we change things to allocate the user on firstboot today.
More on this in https://centos.github.io/centos-bootc/builds/#injecting-users-at-build-time (that could be expanded too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why 501 versus the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just going by the entries in ignition.go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the default user on a MAC is UID=501
|
||
RUN mkdir -p /home/core/.config/systemd/user/default.target.wants; \ | ||
ln -s /home/core/.config/systemd/user/linger-example.service /home/core/.config/systemd/user/default.target.wants/linger-example.service | ||
RUN --mount=type=tmpfs,destination=/var ostree container commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a no-op and unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
COPY containers-etc.conf /usr/etc/containers/containers.conf | ||
COPY delegate.conf /usr/etc/systemd/system/[email protected]/delegate.conf | ||
COPY docker-host.sh /usr/etc/profile.d/docker-host.sh | ||
COPY podman-docker.conf /usr/etc/tmpfiles.d/podman-docker.conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this should be /usr/lib/tmpfiles.d
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved.
contrib/podmanimage/machine/subuid
Outdated
@@ -0,0 +1 @@ | |||
core:100000:1000000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, is there really no way to tweak this on the useradd
commandline? That'd work better...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None that I found.
RUN printf "\nconfdir /etc/chrony.d\n" >> /etc/chrony.conf | ||
|
||
COPY 10-inotify-instances.conf /usr/etc/sysctl.d/10-inotify-instances.conf | ||
COPY 50-podman-makestep.conf /usr/etc/chrony.d/50-podman-makestep.conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also what IMO is way nicer to read and maintain is just to have:
COPY rootfs/etc etc
COPY rootfs/usr usr
And then just drop your files in those directories in git.
There's one example of this here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just used usr and etc, but this was a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will start nasty and request to have comments in all configs and dockerfiles.
Since we can replace some parts that ignition would take at provisiong time to build time, we need comments to keep it maintianable and avoid collective amnesia why something is done the way it is.
|
||
RUN dnf -y update; \ | ||
rpm --setcaps shadow-utils 2>/dev/null; \ | ||
dnf -y install podman subscription-manager crun crun-wasm crun-krun chrony \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need skopeo and buildah?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't but I think it is useful for debugging and difficult to install if they don't exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They add 60M to the disk / container so I feel rather hesitant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I can remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I've quite often wanted the ability to inspect a remote image without fetching it...and that's just in skopeo right? (It would make sense to me to have something like this in podman too...podman image remote-inspect
? Dunno)
As far as buildah, I think it's basically because it's been promoted as a peer to podman build
, and so it goes where podman goes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The funning thing, my story of skopeo being created is exactly this. we wanted docker inspect --remote. So maybe it is time to add podman image inspect --remote
One issue there is inspecting images versus manifest.
--raw versus default. Also --remote might be misinterpreted by CLI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a separate issue. Note that skopeo runs on Win and Mac as well. So I don't think this must be part of the podman machine
where IMO the focus should be on what Podman needs rather than what some developers may find useful. Ideally, users shouldn't need to ssh into the machine.
ADD usr usr | ||
ADD etc etc | ||
|
||
RUN groupadd -g 501 core; useradd -u 501 -g 501 core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the user cannot be made in containerfile due to podman machine init --username
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, if you want to push forward on this, should be user 1000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be fine with removing this, but do we want to set the default user for the case where these is no specified --username and then allow the user to modify it. Might be a case where want to use sysusers.
|
||
RUN dnf -y update; \ | ||
rpm --setcaps shadow-utils 2>/dev/null; \ | ||
dnf -y install podman subscription-manager crun crun-wasm crun-krun chrony \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
long term, i dont think this will work as we will need versioned content ... i.e. podman 5.0, podman 5.1 (or even 5.1.1). I think fedora-coreos-config does this reasonably nicely with YAML that gets read and converted to what you want above. perhaps there is some variable magic we can do here.
No code in podman is changed here ... we could make the claim this is all for hacking ... though I would like to see the claim added to the commit and the containerfile. I have a series of long term questions that remain unanswered here but i'll just note them the best i can (given I had intended to do this work but you beat me to it).
|
I think we want to make it easy for people to find an easy example of building a podman machine. We need to figure out the best way of selecting the podman machine perhaps using build-args. Perhaps something like: ARG PODMAN_VERSION Then build with: This Containerfile would be just be installing To eliminate the stutter. |
An alternative may be to build podman directly inside the Dockerfile. A multistage build with injecting the source. The benefit is that it can be built directly in the upstream release process without any downstream delay/lag. This certainly comes at a cost of it not being a distro build. Just to further sketch out what I mean: FROM $base-image as podman-build
COPY ./ /src/podman
WORKDIR /src/podman
RUN dnf install -y $build-dependencies
RUN make podman
FROM $base-image
COPY --from=podman-build /src/podman/bin/podman /usr/bin/podman
# All the rest |
Move some of the functionality in ignition into the building of a bootc based podman-machine. Signed-off-by: Daniel J Walsh <[email protected]>
OK so to enable Ignition in derived images, just off the top of my head there are probably two major parts:
|
@baude can we update this Containerfile to match the current one you are using? |
Move some of the functionality in ignition into the building of a bootc based podman-machine.
Does this PR introduce a user-facing change?