docker / desktop-linux

Bug reports for Docker Desktop for Linux
https://docs.docker.com/desktop/linux/
82 stars 7 forks source link

Installing docker desktop breaks contain user permissions #252

Open RyanPaiva56 opened 1 month ago

RyanPaiva56 commented 1 month ago

Description

Using Laravel Sail which handles docker for Laravel users works perfectly. If you install Docker Desktop for Linux, containers will no longer have the write access they need to store files like cache.

See this issue for more information:

https://github.com/laravel/sail/issues/81

Uninstalling Docker Desktop resolves the issue.

Reproduce

  1. Install Docker Desktop
  2. Start a container using Laravel Sail
  3. The container startup will fail with this error:

laravel.test-1 | The stream or file "/var/www/html/storage/logs/laravel.log" could not be op
laravel.test-1 | ened in append mode: Failed to open stream: Permission denied
laravel.test-1 | The exception occurred while attempting to log: The /var/www/html/bootstrap
laravel.test-1 | /cache directory must be present and writable.
laravel.test-1 | Context: {"exception":{}}

Expected behavior

Sail works perfectly when you use a minimal docker compose setup instead of docker desktop.

docker version

Client: Docker Engine - Community Version: 27.3.1 API version: 1.47 Go version: go1.22.7 Git commit: ce12230 Built: Fri Sep 20 11:41:00 2024 OS/Arch: linux/amd64 Context: desktop-linux

Server: Docker Desktop 4.34.3 (170107) Engine: Version: 27.2.0 API version: 1.47 (minimum version 1.24) Go version: go1.21.13 Git commit: 3ab5c7d Built: Tue Aug 27 14:15:15 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.7.20 GitCommit: 8fc6bcff51318944179630522a095cc9dbf9f353 runc: Version: 1.1.13 GitCommit: v1.1.13-0-g58aa920 docker-init: Version: 0.19.0 GitCommit: de40ad0

docker info

Client: Docker Engine - Community Version: 27.3.1 Context: desktop-linux Debug Mode: false Plugins: buildx: Docker Buildx (Docker Inc.) Version: v0.16.2-desktop.1 Path: /usr/lib/docker/cli-plugins/docker-buildx compose: Docker Compose (Docker Inc.) Version: v2.29.2-desktop.2 Path: /usr/lib/docker/cli-plugins/docker-compose debug: Get a shell into any image or container (Docker Inc.) Version: 0.0.34 Path: /usr/lib/docker/cli-plugins/docker-debug desktop: Docker Desktop commands (Alpha) (Docker Inc.) Version: v0.0.15 Path: /usr/lib/docker/cli-plugins/docker-desktop dev: Docker Dev Environments (Docker Inc.) Version: v0.1.2 Path: /usr/lib/docker/cli-plugins/docker-dev extension: Manages Docker extensions (Docker Inc.) Version: v0.2.25 Path: /usr/lib/docker/cli-plugins/docker-extension feedback: Provide feedback, right in your terminal! (Docker Inc.) Version: v1.0.5 Path: /usr/lib/docker/cli-plugins/docker-feedback init: Creates Docker-related starter files for your project (Docker Inc.) Version: v1.3.0 Path: /usr/lib/docker/cli-plugins/docker-init sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.) Version: 0.6.0 Path: /usr/lib/docker/cli-plugins/docker-sbom scout: Docker Scout (Docker Inc.) Version: v1.13.0 Path: /usr/lib/docker/cli-plugins/docker-scout

Server: Containers: 3 Running: 0 Paused: 0 Stopped: 3 Images: 3 Server Version: 27.2.0 Storage Driver: overlayfs driver-type: io.containerd.snapshotter.v1 Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 runc Default Runtime: runc Init Binary: docker-init containerd version: 8fc6bcff51318944179630522a095cc9dbf9f353 runc version: v1.1.13-0-g58aa920 init version: de40ad0 Security Options: seccomp Profile: unconfined cgroupns Kernel Version: 6.10.4-linuxkit Operating System: Docker Desktop OSType: linux Architecture: x86_64 CPUs: 16 Total Memory: 7.654GiB Name: docker-desktop ID: 37b0ff65-71be-4a51-8b45-d62cfaec11a7 Docker Root Dir: /var/lib/docker Debug Mode: false HTTP Proxy: http.docker.internal:3128 HTTPS Proxy: http.docker.internal:3128 No Proxy: hubproxy.docker.internal Labels: com.docker.desktop.address=unix:///home/user1/.docker/desktop/docker-cli.sock Experimental: false Insecure Registries: hubproxy.docker.internal:5555 127.0.0.0/8 Live Restore Enabled: false

WARNING: daemon is not using the default seccomp profile

Diagnostics ID

28DF97CF-D7EA-452A-BEA5-79D2C26BAF7F/20241018180350

Additional Info

No response

RyanPaiva56 commented 1 month ago

Having read through the entire thread, users point to the culprit being Docker Desktop's changing of the context from "default" to "desktop-linux".

I see in the docs here that this is intended for some reason:

https://docs.docker.com/desktop/install/linux/#:~:text=Docker%20Desktop%20on%20Linux%20runs,in%20Docker%20Desktop%20for%20Linux.

Can someone familiar with Docker's context system recommend whether additional steps are needed on the Laravel side of things to make this compatible, or is the problem on Docker's side of things?

Further reading into other issues that might be related, this seems like a common issue:

https://github.com/cytopia/devilbox/issues/963#issuecomment-1438939653

Some are resolving it by adding new user groups, but this doesn't feel like the intended user flow for using Docker Desktop. It seems that changing contexts on a local level disrupts file access permissions.

RyanPaiva56 commented 1 month ago

Ok, I did an even deeper dive on this because a stop-gap measure that appeared to work doesn't actually solve the issue. I still run into issues where my IDE can't edit/delete files created within Docker Desktop. Here's what I found:

There was a fix awhile back that prefixed user IDs:

https://github.com/docker/desktop-linux/issues/9

And I think that led to the issue of Docker Desktop file access not working, but Docker Engine does. It's a user ID issue. Docker Engine uses 1000/1000 and Docker Desktop uses 100999/100999. Fixing this issue would likely resolve all of these issues:

https://github.com/docker/desktop-linux/issues/80 https://github.com/docker/desktop-linux/issues/75 https://github.com/docker/desktop-linux/issues/31 https://github.com/docker/desktop-linux/issues/9 https://github.com/docker/desktop-linux/issues/81 https://github.com/docker/desktop-linux/issues/149

Basically, files created within Docker Desktop either get created as root or as 100999 and in both cases, it breaks the ability to manage these files in your IDE or anything outside of the Docker Desktop VM. A person who wants to use Docker Desktop will have to constantly update the chmod and chown for the files.