AlmaLinux / docker-images

Home for AlmaLinux Docker image RootFS files and production version of sources
MIT License
100 stars 27 forks source link

`podman diff` reports `C /etc` (due to `hostname`) #106

Closed adelton closed 11 months ago

adelton commented 11 months ago

Description of problem

This is a continuation of https://github.com/AlmaLinux/docker-images/issues/97, now for /etc/hostname.

Due to bug https://bugzilla.redhat.com/show_bug.cgi?id=1941142 which is present in all recent podman version as well, running podman diff on an AlmaLinux-based container reports C /etc even if nothing in the container changed. It's due to the fact that the container images do not contain /etc/hostname.

Steps to reproduce

$ podman run --name test-diff docker.io/almalinux/8-base date
$ podman diff test-diff
$ podman rm -f test-diff

Actual results

C /etc

Expected results

Nothing output by that podman diff command.

Additional information

I believe that this is caused by /etc/hostname missing on the image, similar to /etc/resolv.conf which got added in https://github.com/AlmaLinux/docker-images/pull/102.

LKHN commented 11 months ago

Thanks for the following the issue.

When I implemented the fix for /etc/resolv.conf file, it didn't show any diff anymore. So, I thought it would be enough.

OS: AlmaLinux OS 9.3 Podman: 4.6.1-5.el9 from Appstream repository.

git clone https://github.com/AlmaLinux/docker-images --single-branch
cd docker-images
podman build -t diff-test -f dockerfiles/al8/Dockerfile.base .
podman run --name test-diff localhost/diff-test date
Fri Nov 24 16:50:35 UTC 2023
podman diff test-diff

Now, I can reproduce the issue if I use the docker.io/almalinux/8-base image. I wonder what is the difference between the registry and local build one. :thinking:

adelton commented 11 months ago

I don't have a good insight into how things are built, as also mentioned in https://github.com/AlmaLinux/docker-images/issues/97#issuecomment-1741755310 where I saw the /etc/resolv.conf in an image I built locally.

LKHN commented 11 months ago

Here is: https://github.com/AlmaLinux/docker-images/blob/a95cef6a11ec939a6fa7b4f1a80cd1a0363b8cbc/docker_utils_functions#L310

LKHN commented 11 months ago

I just built it with docker as the pipeline does, can confirm that podman build creates the /etc/hostname but docker build doesn't.

adelton commented 11 months ago

Ah, so the problem is that during docker build, something is mounted there, so the touch or COPY --from=stage2 or something similar does not affect the resulting layer?

I wonder how Fedora / RHEL UBI images do that ...

LKHN commented 11 months ago

The touch method on #102 solved the half of the issue, what is left to add it for the /etc/hostname too, just tested with docker build and it works.

adelton commented 11 months ago

Ah, that is good news.

LKHN commented 11 months ago

Is anything else good with images? I'd like to hear your valuable feedback before proceed to build and publish with the proposed fix.

adelton commented 11 months ago

This should be the last thing I'm aware of WRT the images content.

LKHN commented 11 months ago

See the /etc/hostname inside the diff. https://github.com/docker-library/official-images/pull/15765#issuecomment-1826177022