Тёмный

Install Docker in WSL 2 without Docker Desktop 

Nick Janetakis
Подписаться 21 тыс.
Просмотров 67 тыс.
50% 1

Опубликовано:

 

21 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 110   
@NickJanetakis
@NickJanetakis Год назад
If you're using Ubuntu 22.04 or Debian 10 / 11 you'll need to make 1 small change from the video. You'll need to run `sudo update-alternatives --config iptables` and choose option (1) from the prompt to install the legacy version of iptables. Once that's installed everything else works 100% the same and Docker will start successfully.
@mrbenny28
@mrbenny28 10 месяцев назад
Thanks for this great video! I just got it all working now after running this command.
@leTRodz
@leTRodz Год назад
Thank you so much! I was struggling with Docker Desktop. This solution worked wonders!
@EbonySeraphim
@EbonySeraphim 9 месяцев назад
Holy crap slowing this video down to .75x makes the dialog seem pretty much normal speed.
@wuziq
@wuziq Год назад
super clear and you addressed all doubts. came here cuz apparently docker-desktop is causing vmmem to max out memory usage. thanks!
@NickJanetakis
@NickJanetakis Год назад
Thanks for watching and no problem!
@shashanksingh4708
@shashanksingh4708 9 месяцев назад
Did it reduce the RAM usage? I am having the same problem
@TVPInterpolation
@TVPInterpolation 3 месяца назад
​@@shashanksingh4708did it? thinking of setting up a second drive with windows, would be interesting to know.
@shashanksingh4708
@shashanksingh4708 3 месяца назад
@@TVPInterpolation I didn't go ahead with the implementation.....
@TVPInterpolation
@TVPInterpolation 3 месяца назад
@@shashanksingh4708 too bad, but thanks for responding!
@thatokhunou7706
@thatokhunou7706 Год назад
Very helpful, thanks mate! I've been struggling to get docker to work without docker-desktop on linux
@thalesquadros-nh6pf
@thalesquadros-nh6pf 2 месяца назад
the lungs pf this man are the strongest of the world, ty for the video
@NickJanetakis
@NickJanetakis 2 месяца назад
Thanks for watching haha.
@VelmaniJ-f2n
@VelmaniJ-f2n 7 месяцев назад
Thanks much dood. it's working perfectly.
@nnutipa
@nnutipa Год назад
Thanks for the video! I will definitely install docker derectly into WSL2, because I have never used GUI, k8s feature
@cacanantes
@cacanantes Год назад
That helped a lot. Thanks for sharing.
@kindalost1
@kindalost1 Год назад
Hi Nick, great vid! is there still a way to avoid using WSL and docker desktop ? aren't there any installers meant to be install docker on windows without WSL ?
@NickJanetakis
@NickJanetakis Год назад
Thanks. I think you can still use the Hyper-V backed Docker Desktop if you wanted to avoid WSL 2 but WSL 2 nowadays is just a Windows app that you can optionally install. If you want to avoid all of that you can manage your own custom Linux based VM.
@golvino
@golvino Год назад
Thanks for taking the time to explain the ins and outs of this. I did not even know we had a choice. I just re-installed my 3 year old 9570 and chose to stay away from DDesktop. Volumes really seem faster. One small thing I will miss is the neat log/terminal pane in the DDesktop container GUI. But Docker Desktop feels like a nuclear powerplant in terms of footprint and I can probably easily add some aliases to my .bashrc to the same effect. On a side note: you mention that your workstation has 16G of RAM. I do not know the type of workflows that you're running, but I have a 32G and 64G machine and the 32G machine sometimes runs a bit short on memory (WSL2 eats memory like pandas on a bamboo gobbling spree) .
@NickJanetakis
@NickJanetakis Год назад
Hi, WSL 2 has issues around not releasing memory and disk space. A few years ago I made a video on how to clear your memory and disk space at: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-4PwClrUCqJM.html, it still applies today. With Docker running directly in the WSL 2 instance you'll want to follow the disk space steps from time to time too.
@golvino
@golvino Год назад
@@NickJanetakis Precious advice! Thanks a lot, Nick.
@aytraf
@aytraf Год назад
Hey Nick, thanks for the tutorial! systemd support in now available on WSL.
@NickJanetakis
@NickJanetakis Год назад
No problem. It does support systemd but it's very unstable, or at least it was a few months ago. If you close your terminal the process would crash or stop after a pretty short amount of time, meaning you'd have to wait for Docker to spin up again when you close your terminal. The method used in this video doesn't have that problem. It stays up until you reboot your machine or kill the whole WSL process.
@henryjesusguillenchacon7531
@henryjesusguillenchacon7531 9 месяцев назад
Hi, great video. It worked fine for me. One extra thing, will there be any way to run docker, with all the previous configuration, but without entering the WSL console? It is that my project is in the windows folders, and the idea is to run docker from the terminal from where the docker-compose document is hosted. Thanks a lot.
@NickJanetakis
@NickJanetakis 9 месяцев назад
Thanks. In this case Docker is installed and running in WSL. You can access Windows files from within WSL. By default your drives will be mounted in the /mnt folder, so you can run something like `cd /mnt/c` if you have a C:\ drive on Windows. Although the volume mount performance using this method will be very slow compared to having files directly in WSL. By the way you can access WSL files in Windows too. You can open a Windows explorer window and goto `\\wsl.localhost\Ubuntu` , assuming you're running Ubuntu in WSL.
@henryjesusguillenchacon7531
@henryjesusguillenchacon7531 9 месяцев назад
I was hoping in my head that it could be run transparently as in docker-desktop, but I'll settle for that information. Again thank you very much and thanks for the quick response. @@NickJanetakis
@gc-yb6fr
@gc-yb6fr Год назад
Great video! I studying up on Docker Swarm and was wondering if it is possible to run multiple instances of docker on the same machine to simulate a swarm environment. Is it possible to extend what you describe to run the service multiple times?
@NickJanetakis
@NickJanetakis Год назад
Hi, thanks. Personally I don't use Swarm but it should work if it works on native Linux. This set up is no different than a straight up legit native Linux environment, so if you wanted to modify your search terms for that, you might be able to find an answer easier.
@Pavelbrov
@Pavelbrov Год назад
Thank you, working!
@UTS-p9s
@UTS-p9s Год назад
Man that's really cool, thanks
@ryanbarnds3533
@ryanbarnds3533 9 месяцев назад
great video. thank, you. Not sure if i accidently hit the 1.5x speed button or you ingested 1.5 buttons of speed.
@NickJanetakis
@NickJanetakis 9 месяцев назад
No problem, thanks for watching. I may have ingested buttons of speed.
@nghiaTrandai-s5g
@nghiaTrandai-s5g 3 месяца назад
Thanks for your tutorial. Could you tell me more about how to connect to the installed docker from another computer (they are all in the same network). I tried but it seem I can only access my app using "localhost" not the "ip" of the computer I installed wsl
@NickJanetakis
@NickJanetakis 3 месяца назад
Hi, try superuser.com/a/1717756 since this is separate from Docker. Replace the port with whatever port you're trying to access.
@ryanstark1869
@ryanstark1869 9 месяцев назад
Thanks, that works for me!
@brianholland7223
@brianholland7223 Год назад
This is amazing. One follow-up question after I've got it running now. I have a 100Gb SSD C: drive that's like 95% full and an 800 Gb spinning drive that's only like 10% full. How can I store all these images on my spinning drive that still has tons of room on it?? 🙏
@NickJanetakis
@NickJanetakis Год назад
Hmm, maybe you could spin up a WSL 2 instance on your HDD and install Docker there? I think if you tried to set a mounted directory just for Docker within an SSD WSL 2 instance you'll get hit pretty hard by disk mount slowness between Windows and WSL 2.
@deyeaus
@deyeaus 4 месяца назад
Have you ever run into an issue where once docker starts you can't access the net from your wsl2 instance? For example you can start a ping and let it run, start docker (in a different terminal window) and a few seconds later the ping will stall, nslookup etc will also fail for anything outside of wsl2. It's very annoying, had been working fine for months prior to this happening. I suspect something in an update/upgrade modified or does not like my config. Using win 11/ Ubuntu 22.04 with systemd. It was auto starting but disabled it to troubleshoot the issue.
@NickJanetakis
@NickJanetakis 4 месяца назад
Every once in a while yes but it seems unrelated to Docker, it's also worth pointing out I'm not using systemd too. If you edit /etc/resolv.conf you can change your nameserver to 8.8.8.8 or 1.1.1.1 to use Google or CloudFlare's DNS and things will start working immediately. The interesting part is right now DNS is working and my nameserver is set to 172.17.112.1 so it's not like I'm always using Google or Cloudflare's DNS, WSL will periodically rewrite this file by default. Something happens with the default WSL nameserver. There is a closed issue about it here: github.com/microsoft/WSL/issues/4285
@deyeaus
@deyeaus 4 месяца назад
@@NickJanetakis I've already tried that, it made no difference unfortunately. Even specifying different DNS when using nslookup failed.
@NickJanetakis
@NickJanetakis 4 месяца назад
@@deyeaus I'm not sure then. I'd suggest Googling for terms around WSL, systemd and Docker along with losing network access. I'd try not using systemd to see if that changes anything, I'm not currently using it so there's a difference there.
@nataliamarquesvieira3107
@nataliamarquesvieira3107 11 месяцев назад
Hi, Nick! In Docker Desktop we can change preferences to mount specific folders in File Sharing. How can I change this preferences using Docker in WSL?
@NickJanetakis
@NickJanetakis 11 месяцев назад
Hi, in the case of WSL 2 you'll be able to directly mount paths into Docker. Usually (but not always) your files will exist in WSL 2's file system in which case you can reference those paths in your Docker volumes. If you're volume mounting files from files outside of WSL 2, you can access them by default in /mnt/c where "c" is the drive name, this is the out of the box experience with WSL 2. Although it's worth mentioning performance is painfully slow if you mount in paths through /mnt (this is a limitation of WSL 2, not Docker). If files are inside of WSL 2's file system Docker volume mount performance is pretty much as good as native Linux.
@nataliamarquesvieira3107
@nataliamarquesvieira3107 11 месяцев назад
@@NickJanetakis Thank you!!
@caliberx
@caliberx 5 месяцев назад
Can't broadcast in Lan network Whenever we run docker container (docker desktop on windows or docker cli on linux) using broadcast IP 0.0.0.0 & bind port, it gets accessible throughout the local network But in this method it does not Do we have a solution to that
@NickJanetakis
@NickJanetakis 5 месяцев назад
Hi, you can try forwarding your process' port within WSL, there's a few solutions (1 liners) posted here: stackoverflow.com/questions/61002681/connecting-to-wsl2-server-via-local-network
@rs3800
@rs3800 11 месяцев назад
I think I missed the part where the *docker client* is configured to use the newly installed docker engine in WSL?
@NickJanetakis
@NickJanetakis 11 месяцев назад
There is no configuration. After installing Docker in the way described in this video you'll have both the engine and the client. The client will "just work" like it does on Linux. Running `docker info` verifies the client can connect to the engine.
@rs3800
@rs3800 11 месяцев назад
@@NickJanetakis yes cool, but what if I have a 2nd WSL distro with docker engine running and want to switch context? Then it helps to understand the underlying "just works"...appreciate if you can point me to some docs.
@NickJanetakis
@NickJanetakis 11 месяцев назад
@@rs3800 Each WSL instance is independent in that case. You'd install Docker in both. Technically you can use a remote Docker host and configure your client to use that, if you wanted to do that you can follow the same instructions for using a remote host on native Linux. I never did it for WSL but I guess you'd use your WSL private IP address.
@sanlues
@sanlues Год назад
Is the docker on wsl free to use if i am working in a company that doesnt fit in free usage policy for docker desktop
@NickJanetakis
@NickJanetakis Год назад
If you're not using Docker Desktop then you won't need a license for it. Running Docker in WSL like we do in this video is comparable to running Docker on native Linux without Docker Desktop. Personally I wouldn't use this as a tactic to avoid paying for a license tho, their price is very fair already.
@michelschuler6132
@michelschuler6132 Год назад
Hello. At first thank you for the awesome video. I tried installing docker in WSL a few times. i get the same error as allways now. even with the "sudo update-alternatives --config iptables". The error Output is : failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.8.7 (legacy): can't initialize iptables table `nat': Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded. (exit status 3) Do you have an Idea?
@NickJanetakis
@NickJanetakis Год назад
Hey, which WSL 2 distro and version are you using?
@michelschuler6132
@michelschuler6132 Год назад
@@NickJanetakis strange. i answered allrady but my comment is gone :P then again. i had WSL 1 active. I upgraded to WSL 2 now it is working.Thank you very much.
@NickJanetakis
@NickJanetakis Год назад
@@michelschuler6132 Oh nice, glad to hear it's all working.
@matthiasstehr2266
@matthiasstehr2266 Год назад
Nice, but all works only with localhost. You can not reach docker ports from a device in your network. For this you have to add port forwarding , when you are not using Docker Desktop. Until now I found no solution for this, to use WSL without Docker Desktop on Customer side.
@rescenin
@rescenin Год назад
you can try manually add ip route
@matthiasstehr2266
@matthiasstehr2266 Год назад
@@rescenin you can add an port forwarding, that is what you mean. But Windows firewall blocks all forwarded port by default, so you have also add a firewall rule. But every time you restart wsl you get new IP adresses...
@capocianni1043
@capocianni1043 Год назад
@@matthiasstehr2266 yeah, it changes everytime... Is there a way to fix ip? So it won't change everytime.
@ivanyang2022
@ivanyang2022 Год назад
yeah I gave up, so much trouble to make it work.
@saivinherkar2619
@saivinherkar2619 Год назад
Thanks for the video. I did all the steps from video and document. But still my docker daemon is not running. I added script in .profile folder also. Any help would be really appreciated. Thanks!
@NickJanetakis
@NickJanetakis Год назад
Are you using WSL 2?
@JaviHabana
@JaviHabana Год назад
Thanks for the video men, is very usefull
@GamePlayByFaks
@GamePlayByFaks Год назад
Ironic, recently tried and failed to start it in wsl 2, seems stars are alinged since got your video, you got same idea as me.
@GamePlayByFaks
@GamePlayByFaks Год назад
hmm, odd did fresh install on wsl of Ubuntu and did all and it doesn't start, maybe you missed something out ?
@NickJanetakis
@NickJanetakis Год назад
@@GamePlayByFaks Did you add the shell script to your bash profile or equivalent file that's in the video? That's the part that would start Docker. I set this up personally on my box about 2 months ago, these were the only steps I took. Are you using Ubuntu 20.04 or 22.04?
@GamePlayByFaks
@GamePlayByFaks Год назад
@@NickJanetakis 22.04 and did added on bash, and that was odd.
@NickJanetakis
@NickJanetakis Год назад
@@GamePlayByFaks I see, Ubuntu 22.04 has some quirks, but I was able to find a working solution which I just tried on a fresh Ubuntu 22.04 WSL 2 install and it worked. Run this: sudo update-alternatives --config iptables Then choose option "1", now the command to start Docker will work. After closing your terminal and opening a new one you'll be able to run `docker info` successfully which verifies you can connect to the server without needing sudo and that it's running. No need to reboot or restart WSL.
@NickJanetakis
@NickJanetakis Год назад
Thanks a lot for calling this out btw, I pinned a comment for Ubuntu 22.04 support and updated my blog post to mention this step.
@Thiago-p5q6l
@Thiago-p5q6l 11 дней назад
not sure I get the ~/.profile step, you're running a windows program (wsl.exe) from inside the wsl instance? should that really work? in mine it just says "wsl.exe: command not found" (I confirmed that I'm running WSL2)
@NickJanetakis
@NickJanetakis 11 дней назад
It should work yeah, we are calling wsl.exe from within WSL 2. You can try it from the command line with other commands too. For example running `explorer.exe .` should open the Windows explorer at the current directory within WSL 2.
@Thiago-p5q6l
@Thiago-p5q6l 11 дней назад
Ah, it was me all along, i had set appendWindowsPath=false 😅 now all that's left is for the localhost to work from the windows host
@NickJanetakis
@NickJanetakis 11 дней назад
@@Thiago-p5q6l localhost should also work out of the box. For example if you run your app on port 8000 and publish that port with Docker then going to localhost:8000 in your host's browser should work.
@abhiksingh1999
@abhiksingh1999 Год назад
Can windows docker image run on the linux environment? How to run it then?
@NickJanetakis
@NickJanetakis Год назад
Personally I haven't run any Windows based containers. I'm sure there's a way but if that's your primary use case it might be easier with Docker Desktop. If someone else who has experience with this wants to reply, that would be helpful!
@capocianni1043
@capocianni1043 Год назад
Thank you but where is my docker images? I can't find them.
@NickJanetakis
@NickJanetakis Год назад
Hi, everything Docker related is in /var/lib/docker. You can cd into that directory and check things out. You'll need to be the root user.
@capocianni1043
@capocianni1043 Год назад
@@NickJanetakis thank you Nick. Also do we need to map ip from ifnet like you did everytime we reboot the system?
@NickJanetakis
@NickJanetakis Год назад
@@capocianni1043 I never had to map an IP address.
@capocianni1043
@capocianni1043 Год назад
@@NickJanetakis Okay, thank you for replies.
@rodrick89
@rodrick89 10 месяцев назад
You should show the step by step from the beginning of the process so others could follow along or see what possible errors we might encounter. The whole "install this, install that... great! now it works." it's not very helpful.
@NickJanetakis
@NickJanetakis 10 месяцев назад
Hi, which steps weren't covered besides installing WSL 2 itself? Did you encounter any errors? Which error did you get?
@marvellousadesanya8480
@marvellousadesanya8480 Год назад
Got stuck. Can’t find a bash_profile file… or z profile
@NickJanetakis
@NickJanetakis Год назад
What about a ~/.bashrc file? You can also create the ~/.bash_profile file if it doesn't exist.
@marvellousadesanya8480
@marvellousadesanya8480 Год назад
@Nick thanks for your prompt response but I did that. Copied your .z profile file and pasted in a newly created bash_profile file. Sadly the script still didn’t work.
@marvellousadesanya8480
@marvellousadesanya8480 Год назад
You mean I can also add the script to the .bashrc file?
@NickJanetakis
@NickJanetakis Год назад
@@marvellousadesanya8480 Did you open a fresh terminal? Did you reboot? What didn't work exactly? Did it throw an error, did nothing happen, etc.? Also are you running WSL 1 or WSL 2? This will only work with WSL 2.
@NickJanetakis
@NickJanetakis Год назад
@@marvellousadesanya8480 Technically yes. If you're using bash it will execute every time you start a terminal session. If you're not using bash then nothing will happen.
@joelabreurojas
@joelabreurojas 5 месяцев назад
Fish users: # docker if grep -q "microsoft" /proc/version >/dev/null 2>&1 if service docker status 2>&1 | grep -q "is not running" wsl.exe --distribution "(WSL_DISTRO_NAME)" --user root \ --exec service docker start >/dev/null 2>&1 end end
@NickJanetakis
@NickJanetakis 5 месяцев назад
Thanks for adding that!
@pablofuenzalida9565
@pablofuenzalida9565 10 месяцев назад
I'll try this with nvidia docker, if it works, this would me just amazing.
@NickJanetakis
@NickJanetakis 10 месяцев назад
Let us know how it goes.
@pablofuenzalida9565
@pablofuenzalida9565 10 месяцев назад
@@NickJanetakis It went smoothly, Nvidia supports now windows drivers inside WSL2 directly, so no patch of any kind needed to run it
@pablofuenzalida9565
@pablofuenzalida9565 10 месяцев назад
@@NickJanetakis there are some known limitations tho, for example, nvidia docker on wsal2 can only support all the GPUs for now, no option to select just one out of two for an specific container
@meowzhin
@meowzhin Год назад
nice. On thing tho; bro, you talk too damn fast. x)
@redemsion2
@redemsion2 Год назад
Slow your speech down. It doesn't make you any smarter. No need to impress. Focus on disseminating information at a moderate pace so folks can learn from you. All the best.
@jesseb604
@jesseb604 Год назад
Hello Nick J, I am following your video and I cannot get service docker status to work. i am getting the following error when i type service docker status service docker status docker: unrecognized service also when i type 'docker run hello-world' docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. some stats Windows 11 Home i am running wsl2 this is what I get when i type the below in the command prompt admin: wsl -l -v NAME STATE VERSION * Ubuntu Running 2 docker --version Docker version 20.10.21, build 20.10.21-0ubuntu1~22.04.3 docker compose version Docker Compose version v2.19.1 i have also done this part sudo update-alternatives --config iptables 0 /usr/sbin/iptables-nft 20 auto mode * 1 /usr/sbin/iptables-legacy 10 manual mode 2 /usr/sbin/iptables-nft 20 manual mode and my ~/.bashrc file has added this (github.com/nickjj/dotfiles/commit/badd3265e5c8f6eca90d3b57df29292545332500) furthermore i can type docker in ubuntu and I can see all the docker commands available please help :)
@jesseb604
@jesseb604 Год назад
sorry for overloading your comment section. this is what I get when I type docker info docker info Client: Context: default Debug Mode: false Plugins: compose: Docker Compose (Docker Inc., v2.19.1) Server: ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? errors pretty printing info
@longphamthanh3792
@longphamthanh3792 Год назад
@@jesseb604 hey, did you start the docker service? You can add Nick's shell script (at 11:19) to your .bash_profile and restart wsl.
@NickJanetakis
@NickJanetakis Год назад
Thanks for replying. That's what I would suggest too.
@kunalvarpe40
@kunalvarpe40 Год назад
Hi I followed the exact steps in your guide. Bud I am getting below error on docker compose up in my Ubuntu-20.04 WLS distro. Any help will be appriciated user@MACHINE:~/src$ docker compose up -d runtime: g1: frame.sp=0xc00059efd0 top=0xc00059ffe0 stack=[0xc000580000-0xc0005a0000] n=6 max=2147483647 fatal error: traceback did not unwind completely runtime stack: fatal error: unexpected signal during runtime execution panic during panic [signal SIGBUS: bus error code=0x2 addr=0x255cda8 pc=0x4037ee] runtime stack: fatal error: unexpected signal during runtime execution stack trace unavailable
@NickJanetakis
@NickJanetakis Год назад
Hi, Are you running WSL or WSL 2? Did you uninstall Docker Desktop and reboot? Did you install Docker using the steps in this video or something else? What version of Docker do you have? Did you try Googling for those errors? A quick Googling suggests this is maybe from installing a very very old version of Docker github.com/docker/for-linux/issues/285 which wouldn't be the case if you installed Docker using the steps in this video (these steps will give you the latest stable release of Docker). I ran this set up on Ubuntu 20.04 for a while and lots of others too without issues.
@kunalvarpe40
@kunalvarpe40 Год назад
@@NickJanetakis Thank you Nick I did not rebooted my system. After rebooting it worked
Далее
Aprende Docker ahora! curso completo gratis desde cero!
1:29:26
Watching This On Loop ♾️
00:32
Просмотров 10 млн
The intro to Docker I wish I had when I started
18:27
Просмотров 171 тыс.
18 Weird and Wonderful ways I use Docker
26:18
Просмотров 319 тыс.
Install Windows Subsystem for Linux (WSL)
8:41
Просмотров 15 тыс.
WSL 2: Getting started
20:34
Просмотров 719 тыс.
Using Containers without Docker Desktop
20:08
Просмотров 10 тыс.
Windows WSL 2 Docker Tutorial
14:40
Просмотров 14 тыс.