我是靠谱客的博主 健康曲奇,这篇文章主要介绍Win10子系统WSL 使用 docker,现在分享给大家,希望可以做个参考。

Win10子系统WSL 使用 docker

    • docker安装
    • 配置docker
    • 设置ubuntu链接远程docker daemon

安装ubuntu

复制代码
1
2
3
1.在win10商店中安装ubuntu 2.打开ubuntu,安装docker-cli, docker-compose

docker安装

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// # Update the apt package list. sudo apt-get update -y # Install Docker's package dependencies. sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common # Download and add Docker's official public PGP key. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - # Verify the fingerprint. sudo apt-key fingerprint 0EBFCD88 # Add the `stable` channel's Docker upstream repository. # # If you want to live on the edge, you can change "stable" below to "test" or # "nightly". I highly recommend sticking with stable! sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" # Update the apt package list (for the new apt repo). sudo apt-get update -y # Install the latest version of Docker CE. sudo apt-get install -y docker-ce # Allow your user to access the Docker CLI without needing root access. sudo usermod -aG docker $USER # Install Python and PIP. sudo apt-get install -y python python-pip # Install Docker Compose into your user's home directory. pip install --user docker-compose

配置docker

下载Docker Desktop
允许远程连接docker
在这里插入图片描述

设置ubuntu链接远程docker daemon

复制代码
1
2
echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bashrc && source ~/.bashrc

验证是否工作正常
# You should get a bunch of output about your Docker daemon.
# If you get a permission denied error, close + open your terminal and try again.
docker info
# You should get back your Docker Compose version.
docker-compose --version

复制代码
1
2
设置ubuntu的磁盘映射路径,docker需要的路径是/c/Users/nick/dev/myapp, 实际上的挂在路径是/mnt/c/Users/nick/dev/myapp

sudo nano /etc/wsl.conf # 这个文件可能不存在

复制代码
1
2
3
4
5
# Now make it look like this and save the file when you're done: [automount] root = / options = "metadata"

然后重启就可以了

参考链接:setting-up-docker-for-windows-and-wsl-to-work-flawlessly

最后

以上就是健康曲奇最近收集整理的关于Win10子系统WSL 使用 docker的全部内容,更多相关Win10子系统WSL内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(67)

评论列表共有 0 条评论

立即
投稿
返回
顶部