DEV Community

Даниил Пронин
Даниил Пронин

Posted on

Working with Docker and other unix-things on Windows like on macOS or Linux

  1. Install WSL 2
  2. Install Ubuntu (or other distro) into WSL
  3. Place your project files in Linux inside WSL using path like \\wsl$\Ubuntu\home\username\Work. You can access them from using Explorer since it's network location for Windows. Just Enter \\wsl$\ into location bar and you will see available WSL locations. Windows Explorer location autocomplete hints for available WSL locations
  4. Open it in JetBrains IDE JejtBrains IDE Open dialog recognizing Linux filed installed in WSL
  5. Install Docker Desktop for Windows
  6. Enable WSL 2 support in Docker Dashboard Settings Docker Dashboard Settings - Resources - WSL Integration
  7. Open WSL Command Line, go to project folder and initialize Docker configuration. For example: docker-compose up -d.
  8. Now you can see Docker Desktop give you access to containers you just build. Docker Dashboard recognizing containers built in Linux installed in WSL
  9. Now you can work with containers into JetBrains IDE Services pane, connecting to Docker daemon using "Docker for Windows" option. JetBrains IDE - connecting to Docker daemon using "Docker for Windows" option Access to WSL Docker from JetBrains IDE Services pane

TIP after installing Docker Desktop, you can notice you can open Docker frontend in browser, but not frontend from WSL (like npm run start). To fix that, create .wslconfig file in your home folder (C:\Users\username) and fill it:

[wsl2]
memory=4GB
swap=0
localhostForwarding=true
Enter fullscreen mode Exit fullscreen mode

The key you want to change is localhostForwarding.

Found it here.

Top comments (0)