If you use docker to manage an infrastructure or create docker templates, in general you will certainly have your own infrastructure with VMs + portainer for example. Or you use Docker Desktop under Windows, the disadvantage is either to have a small server, or to emulate your machines on your computer if it is powerful enough. Docker Desktop is not really optimized for deploying your future instances. A little tip to let you use Visual Studio code with docker in WSL, yes Visual Studio Code is really a powerful editor.
Install WSL2 (Windows 11)
Open Start on Windows 11 and earch for terminal (or PowerShell), right-click the top result and select the Run as administrator option.
Type the following command to install the WSL on Windows 11 and press Enter : wsl --install
Restart your computer to finish the WSL installation on Windows 11.
Install Ubuntu
Type the following command to view a list of available WSL distros you can install on Windows 11 and press Enter :
wsl --list --online
Quick note: You can install Ubuntu, Debian, Kali Linux, openSUSE, and SUSE Linux Enterprise Server. Type the following command to install the WSL with a specific distro on Windows 11 and press Enter :
wsl --install -d Ubuntu Install docker in WSL2
Here’s the condensed version for Ubuntu and Debian based distros :
# Install Docker, you can ignore the warning from Docker about using WSL curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh # Add your user to the Docker group sudo usermod -aG docker $USER # Install Docker Compose v2 sudo apt-get update && sudo apt-get install docker-compose-plugin # Sanity check that both tools were installed successfully docker --version docker compose version # Using Ubuntu 22.04 or Debian 10 / 11? You need to do 1 extra step for iptables # compatibility, you'll want to choose option (1) from the prompt to use iptables-legacy. sudo update-alternatives --config iptables
We won’t need it but if you decide to enable systemd with newer versions of WSL 2 then you can skip this entire step! All you have to do is drop this into your .profile, .zprofile or equivalent file :
if grep -q "microsoft" /proc/version > /dev/null 2>&1; then if service docker status 2>&1 | grep -q "is not running"; then wsl.exe --distribution "${WSL_DISTRO_NAME}" --user root \ --exec /usr/sbin/service docker start > /dev/null 2>&1 fi fi Install and configure Visual Studio Code
Download and install from here https://code.visualstudio.com/ and in the plugins you have to search plugin: Remote Explorer
In WSL target or CIBLES WSL select Ubuntu and you have to click on the button on the right to access ubuntu wsl :
Visual studio code will open another window and in plugins install Docker, Docker Explorer and Docker Compose and more if you need :
Upload your image docker and you can manage your containers from the list on the left :
You can now your docker instances from wls and have better compatibility to create a future production instance.
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
ArchivesCategories
All
|