Docker安装完成无法pull镜像
原因:
Docker拉取镜像失败
root@DESKTOP-72937KR:~# docker pull registry.cn-hangzhou.aliyuncs.com/bxw-images/xiaoyaliu_alist
Using default tag: latest
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
使用service docker status 查看docker服务,发现Docker服务未启动
root@DESKTOP-72937KR:~# service docker status
* Docker is not running
查看日志
root@DESKTOP-72937KR:/# cat /var/log/docker.log
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to register "bridge" driver: unable to add return rule in DOCKER-ISOLATION-STAGE-1 chain: (iptables failed: iptables --wait -A DOCKER-ISOLATION-STAGE-1 -j RETURN: iptables v1.8.10 (nf_tables): RULE_APPEND failed (No such file or directory): rule in chain DOCKER-ISOLATION-STAGE-1
解决方法:
root@DESKTOP-72937KR:/var/log# sudo update-alternatives --config iptables
There are 2 choices for the alternative iptables (providing /usr/sbin/iptables).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/sbin/iptables-nft 20 auto mode
1 /usr/sbin/iptables-legacy 10 manual mode
2 /usr/sbin/iptables-nft 20 manual mode
Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/sbin/iptables-legacy to provide /usr/sbin/iptables (iptables) in manual mode
root@DESKTOP-72937KR:/var/log# service docker restart
* Starting Docker: docker [ OK ]
root@DESKTOP-72937KR:/var/log# service docker status
* Docker is running
此处引用一个老外遇到同样的问题时候的解释:
[!NOTE]
I noticed iptables being used is a nftables version. Turns out, Starting from version 20.10, Ubuntu switched the firewall system to nftables in like mentoned here; But unfortunately, using nftables natively requires Linux Kernel 5.8, where the latest Kernel version for WSL is 5.4. Fortunately, Ubuntu still have a legacy version of iptables kept in the system. To do it, you can simlpy use update-alternatives --config iptables to change it:
Docker无法拉取阿里云私有仓库的镜像
原因:
Docker拉取失败
root@DESKTOP-72937KR:/var/log# docker pull registry.cn-hangzhou.aliyuncs.com/bxw-images/xiaoyaliu_alist
Using default tag: latest
Error response from daemon: pull access denied for registry.cn-hangzhou.aliyuncs.com/bxw-images/xiaoyaliu_alist, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
解决方法:
root@DESKTOP-72937KR:/var/log# docker login --username=baoxinwen registry.cn-hangzhou.aliyuncs.com
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
root@DESKTOP-72937KR:/var/log# docker pull registry.cn-hangzhou.aliyuncs.com/bxw-images/xiaoyaliu_alist
Using default tag: latest
latest: Pulling from bxw-images/xiaoyaliu_alist
3c854c8cbf46: Pull complete
fe0e33dc13e5: Pull complete
9a4f75e4df14: Pull complete
e0a6cbf3075b: Pull complete
8d83b150288c: Pull complete
9e467971318a: Pull complete
c05889fa915f: Pull complete
21a32044857e: Pull complete
4f4fb700ef54: Pull complete
Digest: sha256:a867e78430a2e3ff3dfe188aff68c5f66bec8a55c5b8df9439b2ec629afe041c
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/bxw-images/xiaoyaliu_alist:latest
registry.cn-hangzhou.aliyuncs.com/bxw-images/xiaoyaliu_alist:latest