Skip to content

[BUG] permission denied on .env file in current directory lead to error #14166

Description

@Ptipoi-jf

Description

my current use case is using a sudo command to execute a tool that execute some docker commands...

to simplify the problem, running the following command fail with a permission denied (and btw the .env file did not exists)

[root@myhost ~]# sudo -u myuser docker compose -p myproject ps -a --format "{{.ID}}|{{title .Status}}|{{.Ports}}"
stat /root/.env: permission denied
[root@myhost ~]# sudo -u myuser docker compose ps -a --format "{{.ID}}|{{title .Status}}|{{.Ports}}"
stat /root/.env: permission denied

With current working directory changes it work as expected (no .env file in the /tmp directory)

[root@myhost ~]# cd /tmp
[root@myhost tmp]# sudo -u myuser docker compose ps -a --format "{{.ID}}|{{title .Status}}|{{.Ports}}"
no configuration file provided: not found
[root@myhost tmp]# sudo -u myuser docker compose -p myproject ps -a --format "{{.ID}}|{{title .Status}}|{{.Ports}}"
29ddbf36662e|Exited (0) 4 Minutes Ago|
05ed8afdf90d|Exited (0) 4 Minutes Ago|
797d87bcc51e|Exited (0) 4 Minutes Ago|
6be65b4385c5|Exited (0) 4 Minutes Ago|

Why do not just print a warning for this permission denied ?
Is there an acceptable workarround for this ?

Thanks fj

Compose Version

docker-compose-plugin-5.5.0-1.el9.x86_64

Docker Environment

RedHat 9
container-selinux-2.235.0-1.el9_6.noarch
docker-ce-cli-29.7.2-1.el9.x86_64
containerd.io-2.3.4-1.el9.x86_64
docker-ce-rootless-extras-29.7.2-1.el9.x86_64
docker-ce-29.7.2-1.el9.x86_64

Anything else?

i didn't test in different system, i guess it working like this

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions