Build docker environment with WSL

Introduction

I tried to run docker from wsl and it melted for a whole day so I will record it.

Also, I intentionally wrote "WSL", but the prerequisites are as follows.

--Windows OS build 19041 and above --Being WSL2 --Starting the command prompt with administrator privileges --Docker version is 17.12.1 --You must have an account on docker hub

As mentioned above, it seems that it actually has to be WSL2. However, I spent a whole day at WSL, and I think that there are other people who are in trouble because they are trying hard at WSL, so I intentionally chose this title.

By the way, even WSL1 succeeds until the last hello-world. After that, when I try to put the package using ** apt-get, it doesn't work at all. ** ** Therefore, ** it is recommended to keep it in WSL2 for later work. ** **

step1: Windows update

You can update from the following page. [https://www.microsoft.com/ja-jp/software-download/windows10:embed:cite]

step2: Change to WSL2

I proceeded with reference to the following article. [https://dev.classmethod.jp/articles/how-to-setup-wsl2/:embed:cite] By the way, I already had Ubuntu on WSL, so I did the following without installing a new Ubuntu to get my existing Ubuntu to work on WSL2.

wsl --set-version Ubuntu 2

step3: Install docker

Launch wsl and do the following:

sudo apt install docker.io=17.12.1-0ubuntu1

In addition, add docker as a secondary group to your group.

sudo usermod -aG docker $USER

launch docker daemon

Do the following:

sudo cgroupfs-mount && sudo service docker start

Make sure it is running with the following command

sudo service docker status

It is OK if it is displayed as follows.

*docker running

Let's run the following to see if it starts successfully.

sudo docker run hello-world

It is OK if it is displayed as follows.

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Recommended Posts

Build docker environment with WSL
Build Couchbase local environment with Docker
Build a Node.js environment with Docker
Build PlantUML environment with VSCode + Docker
Build environment with vue.js + rails + docker
Build docker + laravel environment with laradock
Build Java development environment with WSL2 Docker VS Code
Build a PureScript development environment with Docker
Explode Docker with WSL2
Build a Wordpress development environment with Docker
[Docker] Build Jupyter Lab execution environment with Docker
Build an environment with Docker on AWS
Build TensorFlow operation check environment with Docker
How to build Rails 6 environment with Docker
Build Go development environment with WSL2 + Docker Desktop + VSCode (Remote --Containers)
Build a Laravel / Docker environment with VSCode devcontainer
Build mecab (NEologd dictionary) environment with Docker (ubuntu)
[Rails] How to build an environment with Docker
[First team development ②] Build an environment with Docker
Pytorch execution environment with Docker
WSL2 + VSCode + Docker development environment
Docker autostart settings with wsl2
[Docker] Rails 5.2 environment construction with docker
React environment construction with Docker
Build DynamoDB local with Docker
How to build docker environment with Gradle for intelliJ
Build an environment of Ruby2.7.x + Rails6.0.x + MySQL8.0.x with Docker
Easily build a Vue.js environment with Docker + Vue CLI
[Note] Build a Python3 environment with Docker in EC2
Build Rails (API) x MySQL x Nuxt.js environment with Docker
Build WordPress environment with Docker (Local) and AWS (Production)
Comfortable Docker environment created with WSL2 CentOS7 and Docker Desktop
Create Chisel development environment with Windows10 + WSL2 + VScode + Docker
Create a Vue3 environment with Docker!
Node.js environment construction with Docker Compose
Build a Tomcat 8.5 environment with Pleiades 4.8
Environment construction with Docker for beginners
Create SolrCloud verification environment with Docker
Create Laravel environment with Docker (docker-compose)
Build jooby development environment with Eclipse
[Environment construction with Docker] Rails 6 & MySQL 8
Build Unity development environment on docker
Build WebRTC Janus with Docker container
Spring Boot gradle build with Docker
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Express ~
How to build Rails, Postgres, ElasticSearch development environment with Docker
Build a Node-RED environment with Docker to move and understand
I tried to build the environment of WSL2 + Docker + VSCode
Build apache7.4 + mysql8 environment with Docker (with initial data) (your own memo)
GPU environment construction with Docker [October 2020 version]
Rails environment construction with Docker (personal apocalypse)
Building Rails 6 and PostgreSQL environment with Docker
Laravel development environment construction with Docker (Mac)
Create Rails 6 + MySQL environment with Docker compose
I tried to build the environment of PlantUML Server with Docker
Environment construction with Docker (Ubuntu20.04) + Laravel + nginx
Edit Mysql with commands in Docker environment
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ MySQL edition ~
Create a MySQL environment with Docker from 0-> 1
Build a WAS execution environment from Docker
Create Spring Boot-gradle-mysql development environment with Docker