Volume mounts not working Kubernetes and WSL 2 and Docker

According to the following thread, hostPath volumes are not officially supported for wsl2, yet. They do suggest a workaround, though I had trouble getting it to work. I have found that prepending /run/desktop/mnt/host/c seems to work for me. // C:\someDir\volumeDir hostPath: path: /run/desktop/mnt/host/c/someDir/volumeDir type: DirectoryOrCreate Thread Source: https://github.com/docker/for-win/issues/5325 Suggested workaround from thread: https://github.com/docker/for-win/issues/5325#issuecomment-567594291

Docker loading kernel modules

In Linux host: Run the container in privileged mode (–privileged) Add all capabilities (–cap-add=ALL) mount host /lib/modules into the container (-v /lib/modules:/lib/modules) docker run –name container_name \ –privileged \ –cap-add=ALL -d \ -v /dev:/dev \ -v /lib/modules:/lib/modules \ image_id Caution: Here all Linux capabilities are added so capabilities can be refined. Few words about Linux … Read more

boot2docker startup script to mount local shared folder with host

/var/lib/boot2docker/bootlocal.sh fits your need probably, it will be run by initial script /opt/bootscripts.sh And bootscripts.sh will also put the output into the /var/log/bootlocal.log, see segment below (boot2docker 1.3.1 version) # Allow local HD customisation if [ -e /var/lib/boot2docker/bootlocal.sh ]; then /var/lib/boot2docker/bootlocal.sh > /var/log/bootlocal.log 2>&1 & fi One use case for me is I usually put … Read more

Substitute environment variables in NGINX config from docker-compose

Since nginx 1.19 you can now use environment variables in your configuration with docker-compose. I used the following setup: # file: docker/nginx/templates/default.conf.conf upstream api-upstream { server ${API_HOST}; } # file: docker-compose.yml services: nginx: image: nginx:1.19-alpine volumes: – “./docker/nginx/templates:/etc/nginx/templates/” environment: NGINX_ENVSUBST_TEMPLATE_SUFFIX: “.conf” API_HOST: api.example.com I’m going off script a little from the example in the documentation. … Read more

Docker add network drive as volume on windows

My colleague came up with this and it works with our company network drive and it might help someone out there. We start by creating a docker volume named mydockervolume. docker volume create –driver local –opt type=cifs –opt device=//networkdrive-ip/Folder –opt o=user=yourusername,domain=yourdomain,password=yourpassword mydockervolume –driver specifies the volume driver name –opt Sets driver specific options. I guess … Read more