Try   HackMD

WSL 安裝 Docker

WSL 下輸入

# Step 1: Update Software Repositories
sudo apt-get update

# Step 2: Uninstall Old Versions of Docker
sudo apt-get remove docker docker-engine docker.io

# Step 3: Install Docker
sudo apt install docker.io

# Step 4: Start and Automate Docker
sudo systemctl start docker
sudo systemctl enable docker

# Step 5 (Optional): Check Docker Version
docker --version

如果出現錯誤訊息

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

記得輸入啟動 Docker 指令

sudo service docker start

如果是 WSL 是無法啟動 Docker

參考網路技術分享文章:
https://blog.csdn.net/u012814856/article/details/86130341
因為 WSL 不支援 Docker 進程
解決方法請參考網路技術分享文章:
https://www.cnblogs.com/xiaoliangge/p/9134585.html

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

開啟黃色 Expose daemon on tcp://localhost:2375 without TLS
再 WSL 上輸入指令

export DOCKER_HOST=tcp://127.0.0.1:2375

vim ~/.bashrc

# 在 ~/.bashrc 最後一行新增一行指令
export DOCKER_HOST=tcp://0.0.0.0:2375

source ~/.bashrc

讓 WSL 連接到 Docker for Windows
就能正常的在 WSL 上使用 Docker

tags: WSL Docker 工作紀錄