本文不是写Docker是什么和Docker怎么用,而是记录Docker使用中碰到的问题和排查解决方式
1. 以非root用户运行docker
$sudo groupadd docker #确保有docker用户组
$sudo usermod -aG docker $USER #将当前用户加入docker用户组
登出并重新登录后生效
验证:
$docker ps
2. 查看registry mirror的更改是否生效
$docker info
查看最下面Registry Mirrors的内容
3. docker 启动失败
错误信息:
$ systemctl status docker.service
docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2020-04-04 21:16:46 CST; 1min 9s ago
Docs: https://docs.docker.com
Process: 3514 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exi
Main PID: 3514 (code=exited, status=1/FAILURE)
4月 04 21:16:46 junwang-OptiPlex-7050 systemd[1]: docker.service: Service hold-off time over, scheduling r
4月 04 21:16:46 junwang-OptiPlex-7050 systemd[1]: docker.service: Scheduled restart job, restart counter i
4月 04 21:16:46 junwang-OptiPlex-7050 systemd[1]: Stopped Docker Application Container Engine.
4月 04 21:16:46 junwang-OptiPlex-7050 systemd[1]: docker.service: Start request repeated too quickly.
4月 04 21:16:46 junwang-OptiPlex-7050 systemd[1]: docker.service: Failed with result 'exit-code'.
4月 04 21:16:46 junwang-OptiPlex-7050 systemd[1]: Failed to start Docker Application Container Engine.
可能的原因:
A:image被破坏,可以尝试 sudo rm -rf /var/lib/docker/*
B:docker配置不符合规范,可以尝试重新编辑 /etc/docker/daemon.json