Programming in Elixir with Docker on Windows

Hello,

few days ago I changed my GPU and I had to switch from Linux to Windows. I consider learning Docker instead of installing Elixir on my machine. Is it worth my time? I’m still learning Elixir basics and I don’t have any experience with Docker, but I thought that maybe it’s a good idea and some kind of investment for the future.

Unfortunately, virtual machines don’t work well on my machine, they are pretty slow and I have bad experience with using them.

Thanks!

If I am using windows, I use WSL2. With this i can treat it as any other Linux machine. You do not need to use docker, but If you did, it has nice integration with WSL.

In WSL, I use asdf for elixir/erlang/nodejs

5 Likes

This is also the best advice I can give as a Windows user.

I’ve been using WSL for the past 2 years with Elixir and the overall experience has been pretty good (especially after some WSL2 tweaks).

2 Likes

You shouldn’t compound one unknown with yet another one. Learn Elixir, don’t learn Elixir and Docker at the same time.

I’m using Windows 10 to write Elixir – but I use a Linux Mint virtual machine and actually code in there. I recommend you go that route.

https://my.vmware.com/en/web/vmware/downloads/info/slug/desktop_end_user_computing/vmware_workstation_player/16_0

My main current machine runs Windows 10, and having come to it from Linux (Fedora) I’ll attest to WSL2 working remarkably well. I brought my Linux dotfiles along (making a few wsl-specific edits here and there), and I have an environment that feels pretty comfortable. Windows terminal is finally good enough to live in. From day to day I hardly notice that I’m effectively working in a VM. Performance is impressive - within a few percent of running Linux on bare metal. You can even use your GPU from WSL (though until the final WSLg release it involves running a Windows Insider build, so probably better to wait a few months for that).

Agree that adding the burden of learning Docker seems like an unnecessary barrier.

1 Like

You can also develop on Windows without using WSL.

1 Like

Went that route before and can’t quite recommend that. The “elixir experience” on pure Windows can become quite frustrating sometimes although it might have changed since the last time I used it. One of the things that ground my gears back then was that IEx autocompletion simply didn’t work (and werl is just not really a good alternative to a terminal workflow. Besides, it is ugly AF)

You are better off just using WSL2 with whatever distro you like best. It’s just easier to set up and you won’t have problems with libraries where UNIX support is first class. Just less headache overall.

IEx autocompletion, no asdf and sometimes symbols/colours in the terminal are weird are what I notice is lacking, but I figure typing everything means I commit things to memory better.

My app is designed to run on Windows only and interacts with other Windows software through a dll, so I don’t have a choice :upside_down_face:

Thanks for all replies!

I made a small research about Docker and it seems to work a little bit different than I thought. I just set up WSL2 with Ubuntu and installed elixir (sudo apt install erlang elixir), but I have some troubles with ElixirLS.

Capture

Install elixir and erlang with asdf or using the instructions from Installing Elixir - The Elixir programming language, the versions available on the default repos for ubuntu 20.04 (which is the most common in WSL2) aren’t that updated.

IIRC the default elixir version in the ubuntu repos is 1.9 and elixir-ls depends on 1.10.

Thanks, I updated elixir to 1.12, but I still get error ‘server crashed 5 times in the last 3 minutes’, no matter if I try in WSL Remote or not.

Can you remove the _build and .elixir_ls folders at the root of the project and let it rebuild again?

I removed _build folder and nothing changed, but .elixir_ls doesn’t even exist.

It means that the lsp isn’t even starting, I don’t know if the esl-erlang package provides the erlang in the same way as the ubuntu package, did you updated the erlang package too or only the elixir?

By the way, did you use the repo or asdf to update?

I removed previously installed packages and installed them again, this time following elixir docs.

If you do want to go with docker at some point, this seems like a good article about docker+elixir How to set up a development environment for Phoenix Framework with Docker Compose | dwarftech

Perhaps check out the troubleshooting tips at GitHub - elixir-lsp/vscode-elixir-ls: Elixir language support and debugger for VS Code, powered by Eli (the image you posted looks like vscode?). What do you get if you type elixir at the same prompt you launch vscode from?

If you don’t find anything, perhaps add a post here with some more info about exactly how you’re opening a project in vscode (eg. is it from the command line at the root of a mix project?), and maybe scan the elixir-ls log output & include anything that seems relevant.

Ok, I solved problem by switching from Ubuntu to OpenSUSE Leap 15.3. I don’t know what exactly caused this error, but default elixir (1.11.3) and erlang packages from repository seem to work just fine.

Thanks for all replies, I appreciate that. At this moment I will not learn docker and just go with WSL2.

1 Like

I have one more question. I’m trying to setup postgres on WSL. I installed postgresql and postgresql-server, but I can’t start the service.

Can I somehow enable postgres service without systemd?

I assume you were trying to start it with systemctl, which won’t work without systemd. Not sure what OpenSUSE comes with, but most distros have service to run System V init scripts [edit - system can also start systemd units, which most packages designed, like postgres, to be run as services will install these days]. Try which service to see if you have it, then if it’s there, man service to read up on how to use it.

If things are set up right, sudo service postgresql start should get you started. I admit I haven’t gone to the trouble of automating starting services in my wsl - as my system keeps running for weeks on end it’s no trouble to just run this on reboot. But it can be done if needed.