Last active
August 17, 2022 16:37
-
-
Save Guddiny/e2cac200d8100a3926777109f770228b to your computer and use it in GitHub Desktop.
Install and setup docker on WSL2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install ubuntu into WSL2 | |
# https://www.microsoft.com/en-us/p/ubuntu-2004-lts/9n6svws3rx71?activetab=pivot:overviewtab | |
# Run VM and go through next steps | |
# Install Docker | |
sudo apt update | |
sudo apt upgrade -y | |
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | |
echo \ | |
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
sudo apt update | |
sudo apt-get install docker-ce docker-ce-cli containerd.io -y | |
sudo service docker start | |
sudo groupadd docker | |
sudo usermod -aG docker $USER | |
newgrp docker | |
# Check that docker works | |
docker run hello-world | |
# Install Docker Compose | |
sudo apt install docker-compose -y | |
# Create Docker configuration file | |
sudo nano /etc/docker/daemon.json | |
# with content | |
{"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]} | |
# Save file(Ctrl + S - save, Ctrl-x - exit) | |
# and restart Docker | |
sudo service docker restart | |
# Create environment variable | |
# In a project set environment variable before calling some docker API | |
System.Environment.SetEnvironmentVariable("DOCKER_HOST", @"http://localhost:2375"); | |
# or in the system environment variabes | |
### windows - open terminal (CMD) as Administartor | |
setx DOCKER_HOST "http://localhost:2375" /M | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GUI
A simple terminal UI for both docker and docker-compose:
https://github.com/jesseduffield/lazydocker
Installation (Ubuntu):
sudo su
curl https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh | bash