docker / dev-environments

60 stars 32 forks source link

New dev environment fails to populate code volume #112

Open drsgoodall opened 2 years ago

drsgoodall commented 2 years ago

Description

Creating a new dev environment from a git repository fails to populate the volume. The clone appears to work successfully (and if I point to my internal repo it will fail unless I have my ssh key loaded so it is making the connection.) However the language detection fails and it starts up the base dev-environments image rather than a language specific one.

Browsing the the relevant volume in \wsl$\docker-desktop-data\version-pack-data\community\docker\volumes shows an empty _data folder.

This happens with the samples and my own git repos.

Steps to reproduce the issue:

  1. Create a new dev environment using the sample wizard (when there are no existing dev enironments) or via the URL from the documentation (https://github.com/dockersamples/single-dev-env.git ).

Describe the results you received:

Installing credential helpers... done
Cloning into '/code'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 14 (delta 3), reused 9 (delta 1), pack-reused 0
Receiving objects: 100% (14/14), 6.93 KiB | 2.31 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Detecting main repo language...
Unable to detect main repository language.
Unable to detect main repository language.

No files in \wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\volume-single-dev-env-_data

Describe the results you expected: Expected the git checkout files to be in \wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\volume-single-dev-env-_data

Version of Docker Desktop:
You can find the version by clicking on the About Docker Desktop menu

4.6.1 (76265)

Additional information you deem important (e.g. issue happens only occasionally): Only the first time I try after rebooting seems to work. Every subsequent attempt fails. Manually copying files into the volume folder "works" Creating a dev environment from a local folder "works"

It seems to me that the volume never

Output of docker version:

Client: Docker Engine - Community
 Cloud integration: v1.0.22
 Version:           20.10.13
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        a224086
 Built:             Thu Mar 10 14:08:15 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop
 Engine:
  Version:          20.10.13
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       906f57f
  Built:            Thu Mar 10 14:06:05 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.5.10
  GitCommit:        2a1d4dbdb2a1030dc5b01e96fb110a9d9f150ecc
 runc:
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker context show: You can also run docker context inspect context-name to give us more details but don't forget to remove sensitive content.

default

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.8.1)
  compose: Docker Compose (Docker Inc., v2.3.3)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 3
  Running: 3
  Paused: 0
  Stopped: 0
 Images: 6
 Server Version: 20.10.13
 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: 2a1d4dbdb2a1030dc5b01e96fb110a9d9f150ecc
 runc version: v1.0.3-0-gf46b6ba
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.60.1-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 32
 Total Memory: 49.96GiB
 Name: docker-desktop
 ID: 4OMT:FEDS:7VNX:4C7F:TPXA:IAOA:4E3T:GKRW:ZN6T:Y7EC:DALT:4OPQ
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 127
  Goroutines: 142
  System Time: 2022-04-22T08:58:47.770161693Z
  EventsListeners: 5
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support

Additional environment details (AWS ECS, Azure ACI, local, etc.): Running on up to date Windows 10 with wsl 2 (docker output from Ubuntu 20.04 wsl2 distribution. I have also tried with the "Ubuntu" wsl2 distribution)

drsgoodall commented 2 years ago

I've a bit of further testing.

I deleted and re-added "ubuntu-20.04" as my default image. - Can repeatably install the sample. I added the snippet below to setup my ssh-agent - Can repeatably install the sample. I run "wsl" to load up the ssh-agent - Can repeatably install the sample. I run "wsl" and ssh-add in the terminal to load in my ssh key - Sample stops working. I run "wsl" and killall ssh-agent in the terminal, then re-run "wsl" to initialise a new agent - Sample starts working again. I run "wsl" then ssh-keygen to create a new ssh key without a password and add that to my agent - Sample stops working.

SSH Agent snippet added to ~/.profile

SSH_ENV="$HOME/.ssh/agent-environment"
function start_agent {
    echo "Initialising new SSH agent..."
    /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
    echo succeeded
    chmod 600 "${SSH_ENV}"
    . "${SSH_ENV}" > /dev/null
}
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
    . "${SSH_ENV}" > /dev/null
    ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
        start_agent;
    }
else
    start_agent;
fi
drsgoodall commented 2 years ago

By ignoring the ssh instructions in the dev environments instructions and following the instructions for Windows ssh-agent as a service here I was able to clone my own repository into a volume. My wsl no longer has a ssh agent running in it.

kereis commented 2 years ago

By ignoring the ssh instructions in the dev environments instructions and following the instructions for Windows ssh-agent as a service here I was able to clone my own repository into a volume. My wsl no longer has a ssh agent running in it.

I also had the issue that no source code files were present inside the dev environment container. I had the SSH agent running inside WSL too. So I removed the code snippet of the Docker documentation for auto-starting the SSH agent inside WSL and followed the instruction that was linked by @drsgoodall. Afterwards, the source code is available inside the Docker Dev Environment container.

hedleym commented 2 years ago

Same issue for me. If I kill ssh-agent in my WSL/Ubuntu session, the sample dev environment configuration completes.