ITPub博客

首页 > 云计算 > > WSL中安装Docker

WSL中安装Docker

作者:浪花小雨滴 时间:2020-05-11 18:05:44 0 删除 编辑

2019.07.20更新:

赫莉:WSL 2中安装Docker​zhuanlan.zhihu.com图标

Linux子系统(Windows Subsystem for Linux ,WSL)是Win10近几个更新中为数不多的亮点。它并不是虚拟机,只是一个模拟环境,因而并不能完全实现Linux中的各种操作,而且性能也不如一般的虚拟机。得益于此,WSL与windows交互非常方便,消耗非常低,没有启动时间,用来做轻量开发或测试很适合。

网上关于如何在WSL中安装Docker有很多教程,大多时间较早,都面临着需要安装Docker for Windows的问题,这就需要运行虚拟机,对于我资源吃紧的笔记本还是有些负担,而且对于没有Win10 Pro(Hyper-V)的用户也不方便安装。Win10创意者更新后,在WSL中运行Docker Engine成为可能,当然这个功能正在逐步完善中,当前并不能支持docker全部指令。

本机环境

Win10 Pro 1803

安装WSL

  1. 设置==>安全和更新==>开发者选项==>开发人员模式
  2. Microsoft Store==>搜索Linux==>安装Ubuntu16.04 (有兴趣的朋友可以尝试其他版本

WSL中安装Docker

启动WSL控制台,执行以下指令

sudo apt update
sudo apt install docker.io
sudo usermod -aG docker $USER

随后再以管理员启动WSL控制台,执行

sudo cgroupfs-mount
sudo service docker start

测试安装结果

$ docker version
Client:
 Version:      1.13.1
 API version:  1.26
 Go version:   go1.6.2
 Git commit:   092cba3
 Built:        Thu Nov  2 20:40:23 2017
 OS/Arch:      linux/amd64

Server:
 Version:      1.13.1
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.6.2
 Git commit:   092cba3
 Built:        Thu Nov  2 20:40:23 2017
 OS/Arch:      linux/amd64
 Experimental: false

 $ docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:3e1764d0f546ceac4565547df2ac4907fe46f007ea229fd7ef2718514bcec35d
Status: Downloaded newer image for hello-world:latest

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/engine/userguide/

显示如上信息,就表示可以正常使用了,需要注意的是每次电脑重启后先执行cgroupfs-mount再启动docker服务,目前并不完善,期待巨硬能做的更好。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31537575/viewspace-3153291/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: HBase列值比较器
请登录后发表评论 登录
全部评论

注册时间:2018-05-16

  • 博文量
    4259
  • 访问量
    40117