开始前,我们先看看昨天安装的Ubuntu的IP地址:
文章图片
IP地址相同,所以不担心联网的问题了。
Docker的安装方式有多种,自动安装,手动安装,shell安装。我们选择用手动安装,看看踩到那些坑。
先执行卸载旧版本的Docker,因为之前没有安装过,所以提示not installed。
sudo apt-get remove docker docker-engine docker.io containerd runc
文章图片
我们电脑在公网上,又是首次安装学习,所以我们采用从公网的Docker仓库来安装。
一、设置存储库
1、更新apt包索引并安装包以允许apt通过 HTTPS 使用存储库:
安装过程需要耗费一点时间,开始执行:
sudo apt-get update
sudo apt-get install ca-certificates
文章图片
sudo apt-get install curl
文章图片
sudo apt-get install gnupg
文章图片
sudo apt-get install lsb-release
文章图片
2、添加 Docker 的官方 GPG 密钥:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
3、设置Docker仓库,默认设置官方仓库。
echo \
"deb [arch=$(dpkg --print-architecture) 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
stable包含night和test
Stable
Year-month releases are made from a release branch diverged from the master branch. The branch is created with format ., for example 20.10. The year-month name indicates the earliest possible calendar month to expect the release to be generally available. All further patch releases are performed from that branch. For example, once v20.10.0 is released, all subsequent patch releases are built from the 20.10 branch.
Test
In preparation for a new year-month release, a branch is created from the master branch with format YY.mm when the milestones desired by Docker for the release have achieved feature-complete. Pre-releases such as betas and release candidates are conducted from their respective release branches. Patch releases and the corresponding pre-releases are performed from within the corresponding release branch.
Nightly
Nightly builds give you the latest builds of work in progress for the next major release. They are created once per day from the master branch with the version format:
0.0.0-YYYYmmddHHMMSS-abcdefabcdef
where the time is the commit time in UTC and the final suffix is the prefix of the commit hash, for example 0.0.0-20180720214833-f61e0f7.
These builds allow for testing from the latest code on the master branch. No qualifications or guarantees are made for the nightly builds.
安装 Docker 引擎
1,更新apt包索引,安装最新版本的Docker Engine和containerd
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
文章图片
2,如果要安装指定版本,在 repo 中列出可用版本,然后选择并安装:
列出可用版本:
apt-cache madison docker-ce
【docker|Docker自学笔记2-Docker在win11的Ubuntu安装踩坑之路】mirror@DESKTOP-6EEG99D:~$ apt-cache madison docker-ce
docker-ce | 5:20.10.123-0ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
docker-ce | 5:20.10.113-0ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
docker-ce | 5:20.10.103-0ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable
版本很多,只列了最新三个。
安装特定版本:
sudo apt-get install docker-ce=
比如我们选择次新版本:
sudo apt-get install docker-ce=5:20.10.11~3-0~ubuntu-bionic docker-ce-cli=5:20.10.11~3-0~ubuntu-bionic containerd.io
Need to get 60.0 MB of archives.没安装一次,我都看看我的C槽。
文章图片
3,通过运行hello-world 映像来验证 Docker 引擎是否已正确安装。
sudo docker run hello-world
mirror@DESKTOP-6EEG99D:~$ sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See ‘docker run --help’.
报错??????why
重启docker服务试试:
sudo service docker start
mirror@DESKTOP-6EEG99D:~$ sudo service docker start
- Starting Docker: docker
还是不行:
文章图片
慌了,才开始啊,下马威吗。仔细想想是不是我们安装的docker版本太新,卸载了试试:
sudo apt-get purge docker-ce=5:20.10.11~3-0~ubuntu-bionic docker-ce-cli=5:20.10.11~3-0~ubuntu-
bionic containerd.io
重新安装一个旧一点,当然也不能太旧了:
sudo apt-get install docker-ce=5:18.09.0~3-0~ubuntu-bionic docker-ce-cli=5:18.09.0~3-0~ubuntu-bionic containerd.io
仍然报错:docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
看看log是什么原因吧
sudo vi /var/log/docker.log
找到一些告警信息
time="2022-01-09T13:49:10.222619700+08:00" level=warning msg="Your kernel does not support cgroup memory limit"
time="2022-01-09T13:49:10.222639600+08:00" level=warning msg="Unable to find cpu cgroup in mounts"
time="2022-01-09T13:49:10.222657100+08:00" level=warning msg="Unable to find blkio cgroup in mounts"
time="2022-01-09T13:49:10.222673400+08:00" level=warning msg="Unable to find cpuset cgroup in mounts"
time="2022-01-09T13:49:10.222726300+08:00" level=warning msg="mountpoint for pids not found"
time="2022-01-09T13:49:10.222976000+08:00" level=info msg="Loading containers: start."
time="2022-01-09T13:49:10.234619500+08:00" level=warning msg="Running modprobe nf_nat failed with message: `modprobe: WARNING: Module nf_nat not found in directory /lib/modules/4.4.0-22000-Microsoft`, error: exit status 1"
time="2022-01-09T13:49:10.246106900+08:00" level=warning msg="Running modprobe xt_conntrack failed with message: `modprobe: WARNING: Module xt_conntrack not found in directory /lib/modules/4.4.0-22000-Microsoft`, error: exit status 1"
Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.6.1: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
从报错来看,是没有正确调整好Windows上运行Ubuntu所需硬体资源。问题待解!!!
推荐阅读
- Spring|Docker安装gitlab及修改gitlab密码
- 青龙面板|青龙面板最新版本2.10.11+(诺兰短信登录)nvjdc详细教程
- docker|Centos安装docker
- docker|docker swarm-服务发现与负载均衡原理分析
- ip代理|什么是IP地址冲突(如何解决IP地址冲突?)
- Docker|(一)简单解释Docker是什么以及Docker安装教程
- docker|win11安装Docker玩转OpenCV梦的开始
- github|【GitHubDailyShare】现代机器学习系统的设计原理以及实现
- windows|windows_正确修改windows用户名(win10/win11)实践过/副作用说明