docker / cli

The Docker CLI
Apache License 2.0
4.93k stars 1.93k forks source link

MacOS docker command create a unexpected folder #3332

Closed adaoud-ims closed 3 years ago

adaoud-ims commented 3 years ago

On MacOS, when running the docker command, I have the ~/.docker/contexts/meta directory created in my current folder.

How to reproduce > docker

the command will create the ~/.docker/contexts/meta directly under my current folder /Users/MYUSER/MYPROJECT/~/.docker/contexts/meta the meta folder is empty.

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Build with BuildKit (Docker Inc., v0.6.3)
  compose: Docker Compose (Docker Inc., v2.0.0)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.8
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e25210fe30a0a703442421b0f60afac609f950a3
 runc version: v1.0.1-0-g4144b63
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.47-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 6
 Total Memory: 1.939GiB
 Name: docker-desktop
 ID: KX3I:ICZN:FNGY:57PF:WICQ:WZRI:YPSX:EEBF:CN2K:2HG5:PV2T:4B6J
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: true
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
thaJeztah commented 3 years ago

Is this happening in any directory where you just type the docker command? I could imagine this happening if a bind-mount was specified for a container, which was using ~ as path (or as part of a compose file), and the path was not evaluated by the shell.

I tried reproducing, but so far haven't been able to πŸ€”

adaoud-ims commented 3 years ago

Yes, in any directory. see below my screenshot in a empty dir : image

Not sure why I have that behaviour. I removed docker desktop and reinstalled from scratch but still the same issue.

thaJeztah commented 3 years ago

I was able to reproduce this by setting the DOCKER_CONFIG environment variable to a path containing a literal ~;

Create a directory for testing:

mkdir repro-3332
cd repro-3332

ls -la
total 0
drwxr-xr-x    2 sebastiaan  staff    64 Oct 12 10:49 ./
drwxr-xr-x  261 sebastiaan  staff  8352 Oct 12 10:51 ../

Set the DOCKER_CONFIG variable to a literal ~/.docker (using single quotes to prevent the shell from expanding it), and run a docker command:

DOCKER_CONFIG='~/.docker' docker version

ls -la
total 0
drwxr-xr-x    3 sebastiaan  staff    96 Oct 12 10:53 ./
drwxr-xr-x  261 sebastiaan  staff  8352 Oct 12 10:51 ../
drwxr-xr-x    3 sebastiaan  staff    96 Oct 12 10:53 ~/

tree -ad
.
└── ~
    └── .docker
        └── contexts
            └── meta

4 directories

Could you check if you have that environment variable set (or any other env-variables related to docker that may be relevant?

adaoud-ims commented 3 years ago

thanks a lot ! it was the issue. I had the DOCKER_CONFIG set to '~/.docker'. Once removed, it was working properly.

thaJeztah commented 3 years ago

πŸŽ‰ good to hear it's resolved!

Thanks for reporting the issue; it could have been a bug somewhere in our code (as handling these "special" paths is not always trivial)

Let me close this ticket