

How to install wsl2 ubuntu + docker + docker-compose
source link: https://gist.github.com/martinsam16/4492957e3bbea34046f2c8b49c3e5ac0
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Activate wsl2
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
wsl --set-default-version 2
Install and Configure Ubuntu
# install ubuntu from the store
# open the ubuntu app
# set username and password
# close the ubuntu app
wsl --set-version Ubuntu 2
Install Docker & Docker-compose on Ubuntu
#Refresh and install packages
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common libssl-dev libffi-dev git wget nano
#Add user group
sudo groupadd docker
sudo usermod -aG docker ${USER}
#Add docker key and repo
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
#Install docker and docker-compose
sudo apt-get install -y docker-ce containerd.io docker-compose
#Install docker-compose (if the previous command failed to install)
sudo curl -sSL https://github.com/docker/compose/releases/download/`curl -s https://github.com/docker/compose/tags | grep "compose/releases/tag" | sed -r 's|.*([0-9]+\.[0-9]+\.[0-9]+).*|\1|p' | head -n 1`/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose
Run docker on startup
echo "sudo service docker start" >> ~/.profile
echo "cd /mnt/" >> ~/.profile
source ~/.profile
Considerations
#To restart wsl (use in case it didn't work)
wsl --shutdown
# to communicate containers don't use localhost, point to: [ubuntu terminal] - the first ip that appears
ip addr | grep eth0 | grep inet
# for for ensuring docker service is running on startup to workaround having to deal with sudo
wsl.exe -u root service docker status || wsl.exe -u root service docker start
Limit resources
- Enter the user's folder. C:\Users\USER
- Create the file: .wslconfig
- Enter the following:
[wsl2]
memory = 4GB # Limits memory
processors = 2 # Limits virtual processors
- Save and restart the LxssManager service
Recommend
-
9
<?xml encoding="utf-8" ??>Introduction Docker Compose is a powerful toolkit to manage multi-container projects provided by the Docker official team. Many popular Docker projects require Docker C...
-
6
// Tutorial //How To Install Docker Compose on Ubuntu 18.04Published on July 9, 2018 · Updated on March 9, 2022English
-
6
// Tutorial //How To Install and Use Docker Compose on Ubuntu 20.04Published on June 5, 2020 · Updated on April 1, 2022English
-
7
// Tutorial //How To Install and Set Up Laravel with Docker Compose on Ubuntu 20.04
-
15
// Tutorial //How To Install and Use Docker Compose on Ubuntu 22.04
-
2
Ubuntu VM/Azure: Install & Run Jenkins in Docker/Docker Compose with persistent container volume located on the external Cloud Data DiskAs you can see from the title that’s a lot of configuration going on here. Basical...
-
4
How to install Docker Desktop on Windows 10 Home edition and WSL2 Requirements Windows 10 64-bit Home, Build 15063 or later. Hyper-V and Containers Windows features must be enabled. BIOS-level hardware vir...
-
1
Setting Up Cypress on Ubuntu WSL2 No clue why the directions for this are buried deep in WLS issues. This is how I setup my Cypress on Ubuntu WSL2 working for both on and off VPN with some corp firewall. Before executing any comma...
-
23
Posted by Merlin on December 14, 2022 |
-
3
Install Android SDK CLI Ubuntu 20.04 WSL2 (Work in Progress) Install Java 8 sudo apt install openjdk-8-jdk-headless Android SDK wget https://dl.google.com/android/repository/comma...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK