0

I'm trying to set up a dev-container in VS code that is able to run docker-compose and spin up some containers. I'm using Windows, so using wsl2 (and have docker desktop installed). I am able to install docker in the dev-container and it runs, but am unable to start up dockerd. I've checked a lot of different articles/questions on the internet, but haven't been able to figure it out.

This is what my container is based on in the dev-container Dockerfile:

ARG VARIANT="3.10-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
RUN curl -fsSL https://get.docker.com | sh

I try running

sudo dockerd --iptables=false --debug

and i get

INFO[2022-12-11T04:11:09.085898954Z] Starting up                                  
DEBU[2022-12-11T04:11:09.086390079Z] Listener created for HTTP on unix (/var/run/docker.sock) 
DEBU[2022-12-11T04:11:09.086417341Z] Containerd not running, starting daemon managed containerd 
INFO[2022-12-11T04:11:09.086941198Z] libcontainerd: started new containerd process  pid=5082
INFO[2022-12-11T04:11:09.086989169Z] parsed scheme: "unix"                         module=grpc
INFO[2022-12-11T04:11:09.087014427Z] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2022-12-11T04:11:09.087045386Z] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock  <nil> 0 <nil>}] <nil> <nil>}  module=grpc
INFO[2022-12-11T04:11:09.087075143Z] ClientConn switching balancer to "pick_first"  module=grpc
WARN[0000] containerd config version `1` has been deprecated and will be removed in containerd v2.0, please switch to version `2`, see https://github.com/containerd/containerd/blob/main/docs/PLUGINS.md#version-header 
INFO[2022-12-11T04:11:09.111311679Z] starting containerd                           revision=a05d175400b1145e5e6a735a6710579d181e7fb0 version=1.6.12
INFO[2022-12-11T04:11:09.123235446Z] loading plugin "io.containerd.content.v1.content"...  type=io.containerd.content.v1
INFO[2022-12-11T04:11:09.123379851Z] loading plugin "io.containerd.snapshotter.v1.aufs"...  type=io.containerd.snapshotter.v1
INFO[2022-12-11T04:11:09.123551588Z] skip loading plugin "io.containerd.snapshotter.v1.aufs"...  error="aufs is not supported (modprobe aufs failed: exec: \"modprobe\": executable file not found in $PATH \"\"): skip plugin" type=io.containerd.snapshotter.v1
INFO[2022-12-11T04:11:09.123594400Z] loading plugin "io.containerd.snapshotter.v1.btrfs"...  type=io.containerd.snapshotter.v1
INFO[2022-12-11T04:11:09.123813437Z] skip loading plugin "io.containerd.snapshotter.v1.btrfs"...  error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs (overlay) must be a btrfs filesystem to be used with the btrfs snapshotter: skip plugin" type=io.containerd.snapshotter.v1
INFO[2022-12-11T04:11:09.123843744Z] loading plugin "io.containerd.snapshotter.v1.devmapper"...  type=io.containerd.snapshotter.v1
WARN[2022-12-11T04:11:09.123877829Z] failed to load plugin io.containerd.snapshotter.v1.devmapper  error="devmapper not configured"
INFO[2022-12-11T04:11:09.123902577Z] loading plugin "io.containerd.snapshotter.v1.native"...  type=io.containerd.snapshotter.v1
INFO[2022-12-11T04:11:09.123943695Z] loading plugin "io.containerd.snapshotter.v1.overlayfs"...  type=io.containerd.snapshotter.v1
INFO[2022-12-11T04:11:09.124044467Z] loading plugin "io.containerd.snapshotter.v1.zfs"...  type=io.containerd.snapshotter.v1
INFO[2022-12-11T04:11:09.124271960Z] skip loading plugin "io.containerd.snapshotter.v1.zfs"...  error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.zfs must be a zfs filesystem to be used with the zfs snapshotter: skip plugin" type=io.containerd.snapshotter.v1
INFO[2022-12-11T04:11:09.124311505Z] loading plugin "io.containerd.metadata.v1.bolt"...  type=io.containerd.metadata.v1
WARN[2022-12-11T04:11:09.124344629Z] could not use snapshotter devmapper in metadata plugin  error="devmapper not configured"
INFO[2022-12-11T04:11:09.124370588Z] metadata content store policy set             policy=shared
INFO[2022-12-11T04:11:09.124478724Z] loading plugin "io.containerd.differ.v1.walking"...  type=io.containerd.differ.v1
INFO[2022-12-11T04:11:09.124525022Z] loading plugin "io.containerd.event.v1.exchange"...  type=io.containerd.event.v1
INFO[2022-12-11T04:11:09.124555250Z] loading plugin "io.containerd.gc.v1.scheduler"...  type=io.containerd.gc.v1
INFO[2022-12-11T04:11:09.124615985Z] loading plugin "io.containerd.service.v1.introspection-service"...  type=io.containerd.service.v1
INFO[2022-12-11T04:11:09.124685808Z] loading plugin "io.containerd.service.v1.containers-service"...  type=io.containerd.service.v1
INFO[2022-12-11T04:11:09.124717539Z] loading plugin "io.containerd.service.v1.content-service"...  type=io.containerd.service.v1
INFO[2022-12-11T04:11:09.124737517Z] loading plugin "io.containerd.service.v1.diff-service"...  type=io.containerd.service.v1
INFO[2022-12-11T04:11:09.124771001Z] loading plugin "io.containerd.service.v1.images-service"...  type=io.containerd.service.v1
INFO[2022-12-11T04:11:09.124811598Z] loading plugin "io.containerd.service.v1.leases-service"...  type=io.containerd.service.v1
INFO[2022-12-11T04:11:09.124847637Z] loading plugin "io.containerd.service.v1.namespaces-service"...  type=io.containerd.service.v1
INFO[2022-12-11T04:11:09.124878826Z] loading plugin "io.containerd.service.v1.snapshots-service"...  type=io.containerd.service.v1
INFO[2022-12-11T04:11:09.124908202Z] loading plugin "io.containerd.runtime.v1.linux"...  type=io.containerd.runtime.v1
INFO[2022-12-11T04:11:09.124998945Z] loading plugin "io.containerd.runtime.v2.task"...  type=io.containerd.runtime.v2
INFO[2022-12-11T04:11:09.125069299Z] loading plugin "io.containerd.monitor.v1.cgroups"...  type=io.containerd.monitor.v1
INFO[2022-12-11T04:11:09.125419756Z] loading plugin "io.containerd.service.v1.tasks-service"...  type=io.containerd.service.v1
DEBU[2022-12-11T04:11:09.125460905Z] No RDT config file specified, RDT not configured 
INFO[2022-12-11T04:11:09.125490351Z] loading plugin "io.containerd.grpc.v1.introspection"...  type=io.containerd.grpc.v1
INFO[2022-12-11T04:11:09.125525187Z] loading plugin "io.containerd.internal.v1.restart"...  type=io.containerd.internal.v1
INFO[2022-12-11T04:11:09.125607123Z] loading plugin "io.containerd.grpc.v1.containers"...  type=io.containerd.grpc.v1
INFO[2022-12-11T04:11:09.125641409Z] loading plugin "io.containerd.grpc.v1.content"...  type=io.containerd.grpc.v1
INFO[2022-12-11T04:11:09.125670845Z] loading plugin "io.containerd.grpc.v1.diff"...  type=io.containerd.grpc.v1
INFO[2022-12-11T04:11:09.125698708Z] loading plugin "io.containerd.grpc.v1.events"...  type=io.containerd.grpc.v1
INFO[2022-12-11T04:11:09.125731540Z] loading plugin "io.containerd.grpc.v1.healthcheck"...  type=io.containerd.grpc.v1
INFO[2022-12-11T04:11:09.125769402Z] loading plugin "io.containerd.grpc.v1.images"...  type=io.containerd.grpc.v1
INFO[2022-12-11T04:11:09.125797887Z] loading plugin "io.containerd.grpc.v1.leases"...  type=io.containerd.grpc.v1
INFO[2022-12-11T04:11:09.125831551Z] loading plugin "io.containerd.grpc.v1.namespaces"...  type=io.containerd.grpc.v1
INFO[2022-12-11T04:11:09.125864313Z] loading plugin "io.containerd.internal.v1.opt"...  type=io.containerd.internal.v1
INFO[2022-12-11T04:11:09.125919709Z] loading plugin "io.containerd.grpc.v1.snapshots"...  type=io.containerd.grpc.v1
INFO[2022-12-11T04:11:09.125951680Z] loading plugin "io.containerd.grpc.v1.tasks"...  type=io.containerd.grpc.v1
INFO[2022-12-11T04:11:09.125978801Z] loading plugin "io.containerd.grpc.v1.version"...  type=io.containerd.grpc.v1
INFO[2022-12-11T04:11:09.126028927Z] loading plugin "io.containerd.tracing.processor.v1.otlp"...  type=io.containerd.tracing.processor.v1
INFO[2022-12-11T04:11:09.126066589Z] skip loading plugin "io.containerd.tracing.processor.v1.otlp"...  error="no OpenTelemetry endpoint: skip plugin" type=io.containerd.tracing.processor.v1
INFO[2022-12-11T04:11:09.126094872Z] loading plugin "io.containerd.internal.v1.tracing"...  type=io.containerd.internal.v1
ERRO[2022-12-11T04:11:09.126133927Z] failed to initialize a tracing processor "otlp"  error="no OpenTelemetry endpoint: skip plugin"
INFO[2022-12-11T04:11:09.126489334Z] serving...                                    address=/var/run/docker/containerd/containerd-debug.sock
INFO[2022-12-11T04:11:09.126939640Z] serving...                                    address=/var/run/docker/containerd/containerd.sock.ttrpc
INFO[2022-12-11T04:11:09.127060220Z] serving...                                    address=/var/run/docker/containerd/containerd.sock
DEBU[2022-12-11T04:11:09.127105035Z] sd notification                               error="<nil>" notified=false state="READY=1"
INFO[2022-12-11T04:11:09.127249406Z] containerd successfully booted in 0.016919s  
DEBU[2022-12-11T04:11:09.130423237Z] Created containerd monitoring client          address=/var/run/docker/containerd/containerd.sock
DEBU[2022-12-11T04:11:09.131826569Z] Started daemon managed containerd            
DEBU[2022-12-11T04:11:09.132817863Z] Golang's threads limit set to 172350         
INFO[2022-12-11T04:11:09.133276546Z] parsed scheme: "unix"                         module=grpc
INFO[2022-12-11T04:11:09.133311483Z] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2022-12-11T04:11:09.133332884Z] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock  <nil> 0 <nil>}] <nil> <nil>}  module=grpc
INFO[2022-12-11T04:11:09.133355918Z] ClientConn switching balancer to "pick_first"  module=grpc
DEBU[2022-12-11T04:11:09.133390327Z] metrics API listening on /var/run/docker/metrics.sock 
INFO[2022-12-11T04:11:09.134727494Z] parsed scheme: "unix"                         module=grpc
INFO[2022-12-11T04:11:09.134768452Z] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2022-12-11T04:11:09.134804090Z] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock  <nil> 0 <nil>}] <nil> <nil>}  module=grpc
INFO[2022-12-11T04:11:09.134828887Z] ClientConn switching balancer to "pick_first"  module=grpc
DEBU[2022-12-11T04:11:09.136599610Z] Using default logging driver json-file       
DEBU[2022-12-11T04:11:09.136631100Z] processing event stream                       module=libcontainerd namespace=plugins.moby
DEBU[2022-12-11T04:11:09.136663782Z] [graphdriver] priority list: [btrfs zfs overlay2 fuse-overlayfs aufs overlay devicemapper vfs] 
DEBU[2022-12-11T04:11:09.136751510Z] zfs command is not available: exec: "zfs": executable file not found in $PATH  storage-driver=zfs
ERRO[2022-12-11T04:11:09.137867145Z] failed to mount overlay: operation not permitted  storage-driver=overlay2
ERRO[2022-12-11T04:11:09.137929453Z] exec: "fuse-overlayfs": executable file not found in $PATH  storage-driver=fuse-overlayfs
ERRO[2022-12-11T04:11:09.138094297Z] AUFS was not found in /proc/filesystems       storage-driver=aufs
ERRO[2022-12-11T04:11:09.138752311Z] failed to mount overlay: operation not permitted  storage-driver=overlay
WARN[2022-12-11T04:11:09.140326691Z] Unable to setup quota: operation not permitted 
DEBU[2022-12-11T04:11:09.140356818Z] Initialized graph driver vfs                 
DEBU[2022-12-11T04:11:09.140520430Z] No quota support for local volumes in /var/lib/docker/volumes: operation not permitted 
WARN[2022-12-11T04:11:09.145493167Z] Your kernel does not support cgroup blkio weight 
WARN[2022-12-11T04:11:09.145540136Z] Your kernel does not support cgroup blkio weight_device 
WARN[2022-12-11T04:11:09.145546618Z] Your kernel does not support cgroup blkio throttle.read_bps_device 
WARN[2022-12-11T04:11:09.145550846Z] Your kernel does not support cgroup blkio throttle.write_bps_device 
WARN[2022-12-11T04:11:09.145570524Z] Your kernel does not support cgroup blkio throttle.read_iops_device 
WARN[2022-12-11T04:11:09.145590302Z] Your kernel does not support cgroup blkio throttle.write_iops_device 
DEBU[2022-12-11T04:11:09.145756468Z] Max Concurrent Downloads: 3                  
DEBU[2022-12-11T04:11:09.145781566Z] Max Concurrent Uploads: 5                    
DEBU[2022-12-11T04:11:09.145786886Z] Max Download Attempts: 5                     
INFO[2022-12-11T04:11:09.145805472Z] Loading containers: start.                   
DEBU[2022-12-11T04:11:09.145871698Z] Option Experimental: false                   
DEBU[2022-12-11T04:11:09.145896815Z] Option DefaultDriver: bridge                 
DEBU[2022-12-11T04:11:09.145916112Z] Option DefaultNetwork: bridge                
DEBU[2022-12-11T04:11:09.145936591Z] Network Control Plane MTU: 1500              
DEBU[2022-12-11T04:11:09.146037693Z] processing event stream                       module=libcontainerd namespace=moby
ERRO[2022-12-11T04:11:09.147450956Z] failed to set to initial namespace, net:[4026533620], initns fd 14: operation not permitted 
INFO[2022-12-11T04:11:09.147624286Z] Default bridge (docker0) is assigned with an IP address 172.18.0.0/16. Daemon option --bip can be used to set a preferred IP address 
DEBU[2022-12-11T04:11:09.147666476Z] Allocating IPv4 pools for network bridge (290e2ac13ff4d994a6dc424aae0de3fc2b3dbd47ac2d70daf202fe32a8c8a933) 
DEBU[2022-12-11T04:11:09.147696063Z] RequestPool(LocalDefault, 172.18.0.0/16, , map[], false) 
DEBU[2022-12-11T04:11:09.147747761Z] RequestAddress(LocalDefault/172.18.0.0/16, <nil>, map[RequestAddressType:com.docker.network.gateway]) 
DEBU[2022-12-11T04:11:09.147795652Z] Request address PoolID:172.18.0.0/16 App: ipam/default/data, ID: LocalDefault/172.18.0.0/16, DBIndex: 0x0, Bits: 65536, Unselected: 65534, Sequence: (0x80000000, 1)->(0x0, 2046)->(0x1, 1)->end Curr:0 Serial:false PrefAddress:<nil>  
ERRO[2022-12-11T04:11:09.147858973Z] failed to set to initial namespace, net:[4026533620], initns fd 14: operation not permitted 
DEBU[2022-12-11T04:11:09.147914869Z] Did not find any interface with name docker0: Link not found 
DEBU[2022-12-11T04:11:09.148010572Z] Setting bridge mac address to 02:42:e2:0a:5b:d3 
DEBU[2022-12-11T04:11:09.148053373Z] Failed to create bridge docker0 via netlink. Trying ioctl 
DEBU[2022-12-11T04:11:09.148099591Z] releasing IPv4 pools from network bridge (290e2ac13ff4d994a6dc424aae0de3fc2b3dbd47ac2d70daf202fe32a8c8a933) 
DEBU[2022-12-11T04:11:09.148126242Z] ReleaseAddress(LocalDefault/172.18.0.0/16, 172.18.0.1) 
DEBU[2022-12-11T04:11:09.148213228Z] Released address PoolID:LocalDefault/172.18.0.0/16, Address:172.18.0.1 Sequence:App: ipam/default/data, ID: LocalDefault/172.18.0.0/16, DBIndex: 0x0, Bits: 65536, Unselected: 65533, Sequence: (0xc0000000, 1)->(0x0, 2046)->(0x1, 1)->end Curr:2 
DEBU[2022-12-11T04:11:09.148240490Z] ReleasePool(LocalDefault/172.18.0.0/16)      
DEBU[2022-12-11T04:11:09.148254947Z] daemon configured with a 15 seconds minimum shutdown timeout 
DEBU[2022-12-11T04:11:09.148274815Z] start clean shutdown of all containers with a 15 seconds timeout... 
DEBU[2022-12-11T04:11:09.148324430Z] found 0 orphan layers                        
DEBU[2022-12-11T04:11:09.148765069Z] Cleaning up old mountid : start.             
INFO[2022-12-11T04:11:09.148953131Z] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
DEBU[2022-12-11T04:11:09.149076141Z] Cleaning up old mountid : done.              
INFO[2022-12-11T04:11:09.149405639Z] stopping event stream following graceful shutdown  error="context canceled" module=libcontainerd namespace=plugins.moby
INFO[2022-12-11T04:11:09.149442914Z] stopping healthcheck following graceful shutdown  module=libcontainerd
DEBU[2022-12-11T04:11:09.149602629Z] received signal                               signal=terminated
DEBU[2022-12-11T04:11:09.149688012Z] sd notification                               error="<nil>" notified=false state="STOPPING=1"
WARN[2022-12-11T04:11:10.150011723Z] grpc: addrConn.createTransport failed to connect to {unix:///var/run/docker/containerd/containerd.sock  <nil> 0 <nil>}. Err :connection error: desc = "transport: Error while dialing dial unix:///var/run/docker/containerd/containerd.sock: timeout". Reconnecting...  module=grpc
failed to start daemon: Error initializing network controller: Error creating default "bridge" network: operation not permitted

and when i try running something like

sudo docker run -v /var/run/docker.sock:/var/run/docker.sock docker

i get docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

  • In general, running a Docker daemon inside a container ([tag:docker-in-docker]) is trickier than it looks, and isn't usually recommended. In the unlikely event you do need it, there's a dedicated `docker:dind` which might be a better starting point. Why are you trying to launch a nested Docker daemon here? – David Maze Dec 11 '22 at 11:38
  • @DavidMaze Trying to set up an open source GitHub repo that people can contribute to as a project. The main and staging branches are deployed on AWS, but I need a way for people to test development locally. Codespaces with dev containers seemed the best option to avoid dealing with support/installation/running issues if I can get this to work. Also not specifically trying to launch a docker container as I did in the example above. That was just to show that it doesn’t connect. I’m not able to launch any containers inside the dev container though docker is running. –  Dec 11 '22 at 15:25
  • If it's helpful to your contributors, include a `Dockerfile` and possibly a `docker-compose.yml` in your repository. You don't need to create a complete development environment for them, and it's highly likely that many potential contributors aren't using VSCode. Avoid DinD here for sure, it's much more complexity than you need. – David Maze Dec 11 '22 at 18:07
  • @DavidMaze it's also affecting my work, as I've started to like to develop in the dev-container (issues in the past with having to completely messing up my environment etc). With dev containers you can just rebuild them and start over. Issue is the file changes in the git container aren't synced to the local Windows repo it looks like. So i can't run a docker compose up on my file changes unless i commit and push from the dev environment and then pull onto my windows repo (since i cant get docker running inside the dev container). –  Dec 11 '22 at 20:06
  • @DavidMaze I know it's starting to seem a bit overly complicated, but if i could somehow get this setup to work, it'd make stuff a lot easier for me in the future as well. –  Dec 11 '22 at 20:07
  • Nevermind it does look like it is syncing the git between the dev container and system now. I just have to bash into the directory from the windows terminal instead of the vs code terminal and i can run the docker commands. Thanks for your help! –  Dec 11 '22 at 20:35

0 Answers0