Repository navigation
Description
Contributing guidelines
- I've read the contributing guidelines and wholeheartedly agree
I've found a bug, and:
- The documentation does not mention anything about my problem
- There are no open or closed issues that are related to my problem
Description
I have a docker container as an Arch-based Linux distro. Usually I create the container and I push it by the build-push-action but when I create and push the container by this action, when I pull the image and run the container, the filesystem root has the following permissions:
drwxr-xr-x root root 26 B Wed Jun 5 10:27:55 2024 .
drwxr-xr-x root root 26 B Wed Jun 5 10:27:55 2024 ..
.rwxr-xr-x root root 0 B Wed Jun 5 10:27:55 2024 .dockerenv
lrwxrwxrwx root root 7 B Sun Apr 7 18:02:30 2024 bin ⇒ usr/bin
drwxr-xr-x root root 0 B Sun Apr 7 18:02:30 2024 boot
drwxr-xr-x root root 420 B Wed Jun 5 10:27:55 2024 dev
drwxrwxrwx root root 140 B Wed Jun 5 10:27:58 2024 etc
drwxr-xr-x root root 12 B Wed Jun 5 10:09:04 2024 home
lrwxrwxrwx root root 7 B Sun Apr 7 18:02:30 2024 lib ⇒ usr/lib
lrwxrwxrwx root root 7 B Sun Apr 7 18:02:30 2024 lib64 ⇒ usr/lib
drwxr-xr-x root root 0 B Sun Apr 7 18:02:30 2024 mnt
drwxr-xr-x root root 30 B Wed Jun 5 10:07:57 2024 opt
dr-xr-xr-x root root 0 B Wed Jun 5 10:27:55 2024 proc
drwxr-x--- root root 20 B Wed Jun 5 10:09:03 2024 root
drwxr-xr-x root root 460 B Wed Jun 5 10:28:00 2024 run
lrwxrwxrwx root root 7 B Sun Apr 7 18:02:30 2024 sbin ⇒ usr/bin
drwxr-xr-x root root 14 B Sun Jun 2 03:31:09 2024 srv
dr-xr-xr-x root root 0 B Wed Jun 5 10:27:55 2024 sys
drwxrwxrwt root root 200 B Wed Jun 5 11:17:53 2024 tmp
drwxrwxrwx root root 10 B Wed Jun 5 10:05:00 2024 usr
drwxr-xr-x root root 44 B Wed Jun 5 10:27:58 2024 var
Look at etc and usr permissions. It creates several issues (like the /etc/sudoers.d being not working if it is world writable`).
When I build the same container locally and I push it by:
git clone https://github.com/Athena-OS/athena-rdp-docker.git
cd athena-rdp-docker
docker buildx build --tag 'athena-rdp:latest' .
docker login
docker push athenaos/rdp:latest
and then I run it by docker run, the permissions are set correctly.
So I have the described issue only when I use docker action. The GitHub workflow I use for it is:
name: Scheduled Publish
on:
schedule:
- cron: '22 4 * * 0'
workflow_dispatch:
jobs:
docker-publish:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Log to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: athenaos/rdp:latestInstructions to run the container are on README of the https://github.com/Athena-OS/athena-rdp-docker repository.
Expected behaviour
/etc and /usr directories and some their subdir should have the right permissions, for example:
drwxr-xr-x root root 3.4 KB Wed Jun 5 10:33:25 2024 etc
drwxr-xr-x root root 162 B Wed Jun 5 10:33:25 2024 usr
Actual behaviour
The filesystem root has the following permissions:
drwxrwxrwx root root 140 B Wed Jun 5 10:27:58 2024 etc
drwxrwxrwx root root 10 B Wed Jun 5 10:05:00 2024 usr
Repository URL
https://github.com/Athena-OS/athena-rdp-docker
Workflow run URL
YAML workflow
name: Scheduled Publish
on:
schedule:
- cron: '22 4 * * 0'
workflow_dispatch:
jobs:
docker-publish:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Log to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: athenaos/rdp:latestWorkflow logs
No response
BuildKit logs
No response
Additional info
No response
Activity
D3vil0p3r commentedon Jun 5, 2024
I further investigated, and I noted that the issue is caused still by
COPY rootfs/ /when it is parsed bybuild-push-action. In practice,build-push-actionwhen copies all the files and directories to the root of the container, it copies them with all write permissions.crazy-max commentedon Jun 12, 2024
Thanks for reporting.
This looks related to BuildKit, not the GitHub action. Building your project with this Dockerfile locally gives the same behavior:
Related issue is here: moby/buildkit#3602
D3vil0p3r commentedon Jun 12, 2024
@crazy-max thanks for the answer. The strange fact is that the mentioned open issue was opened 1 year ago, but I experienced this issue only in the last month... And if I manually build the image, it works correctly. If I use the mentioned GH actions no...
Indeed the latest pushed image in docker hub of Athena OS was built locally and you can see that the permissions are set correctly.
crazy-max commentedon Jun 21, 2024
@D3vil0p3r This seems link to a regression since BuildKit 0.13: moby/buildkit#5066
Can you try with:
- name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: driver-opts: image=moby/buildkit:v0.12.5D3vil0p3r commentedon Jun 22, 2024
Hey @crazy-max by using your workaround, the permissions are set now correctly. Thank you.
I guess that buildkit must fix the issue.
polarathene commentedon Aug 21, 2024
UPDATE: Below can be ignored. The bug was specific to git context, which was not obvious to me 😓
@D3vil0p3r you can update to use BuildKit
0.15.2which should already be the default now with Github CI, so you can revert this. Issue can be closed as resolved 👍Not reproducible with local build context
I cannot seem to reproduce with any of the following buildx builder drivers:
What I did notice was that whatever permissions I had for the directory or files was copied over. And git checkout would apply a umask if any on the host (unrelated to the docker build), which could result in the files for
COPYto be777?For the reproduction attempt I cloned
athena-rdp-dockerlocally (to/tmp) and ranchmod -R 737 rootfs && chown -R 200:200 rootfs, and changed to the minimalDockerfilein the quote above. Then used each--builderarg above.Ownership of
/etcand any files were copied into the container asroot:rootas expected, while permissions for each builder preserved the737value assigned, ifumask 022was relevant to BuildKit0.13.2the permissions should have become715.At the time of the report the workflow was running with (BuildKit
0.13.2was used in this CI run):By the time the June 23rd comment about BuildKit
0.12.5working as a solution, this was the CI environment:I am running on similar version of Docker (
26.1.1) myself, but have the olderbuildx:I'm more inclined that the change may have been due to Docker Engine v24 vs v26? Unless something else differs between environments🤷♂️ (Yep, it was local vs git context)