docker错误集合

docker使用遇到问题Got permission denied while trying to connect to the Docker daemon socket

解决办法 1

使用超级管理员权限,每次都要输入密码,麻烦。

1
2
3
# 使用sudo docker ps或者sudo docker images
sudo docker
sudo docker images

解决办法 2

不需要每次都输入密码,一次设置,一劳永逸。

1
2
3
4
5
# 把普通用户加入到docker组中 
# 这里的普通用户是 wu ,组docker在安装docker的时候,就已经添加了,所以只需要执行两个操作即可:
sudo gpasswd -a $USER docker
newgrp docker
# 将 wu 用户加入docker组之后,发现使用docker ps或者docker images不会提示权限不足了。

01

‘ERROR: for nginx Cannot start service nginx’

报错内容

1
2
3
4
5
6
7
8
9
10
11
lilbai@ecs-205380: docker-compose up -d
/home/lilbai/.local/lib/python3.6/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.
from cryptography.hazmat.backends import default_backend
Starting nginx ...
Starting nginx ... error

ERROR: for nginx Cannot start service nginx: driver failed programming external connectivity on endpoint nginx (439e7ee354ecc5003b1bc1685d0008eee0e0adafc8aab4b86f20f14029ab3036): Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use

ERROR: for nginx Cannot start service nginx: driver failed programming external connectivity on endpoint nginx (439e7ee354ecc5003b1bc1685d0008eee0e0adafc8aab4b86f20f14029ab3036): Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use
ERROR: Encountered errors while bringing up the project.

分析问题

连接不到80端口,可能是80端口被占用了,如果是80端口被占用,直接kill就行

解决问题

进入超级管理员

1
su

查询80端口占用情况

1
2
3
4
root@ecs-205380# netstat -natp | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 20215/nginx: master
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 29080/pure-ftpd (SE
tcp6 0 0 :::21 :::* LISTEN 29080/pure-ftpd (SE

kill占用80端口的程序

kill结束后再查看一次80端口是否还有其他占用

1
2
3
4
root@ecs-205380# kill -9 20215
root@ecs-205380# netstat -natp | grep 80
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 29080/pure-ftpd (SE
tcp6 0 0 :::21 :::* LISTEN 29080/pure-ftpd (SE

构建Dockerfile出错

manifest for java:8 not found: manifest unknown: manifest unknown

解决方法

找不到镜像java:8,将java:8改为java:9就可以了

02java8

“docker build” requires exactly 1 argument. See ‘docker build --help’.

这是我的执行语句

1
docker build -t docker/mydocker

这个语句其实是有错误的,在最后面需要加上一个点

01缺少一个点

正确的写法

在后面家还是那个一个小

1
docker build -t docker/mydocker .

docker新建容器失败

报错内容1:docker: Error response from daemon: driver failed programming external connectivity on endpoint gitlab (xxxx): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 53222 -j DNAT --to-destination 172.17.0.2:80 ! -i docker0: iptables: No chain/target/match by that name. (exit status 1)).

01报错内容

报错内容2:docker: Error response from daemon: Conflict. The container name “/gitlab” is already in use by container “c23e27b22a90a0a050102510436c4c97ce0ce19d8a64807a43113f208d578adc”. You have to remove (or rename) that container to be able to reuse that name. See ‘docker run --help’.

01报错内容2

尝试解决办法(失败了)

查看网卡是否出了问题

02查看网卡

重启docker

03重启继续失败

解决办法:

查看容器ID

1
docker ps -a

删除容器

1
docker rm ID

重启docker

1
systemctl restart docker

再次确定容器不存在了

1
docker ps -a

创建容器

1
2
3
4
5
6
7
8
docker run --detach \
--publish 5321:443 --publish 53222:80 --publish 5323:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest

04删除容器重启docker

ERROR: failed to register layer: Error processing tar file(exit status 1): write /usr/bin/innochecksum: no space left on device

提示Docker外存空间不足,删除一些镜像即可,或者改变Docker的安装路径或者扩大Docker外存即可

我这里删除部分镜像即可解决问题。

1
docker rmi 镜像ID

Command ‘doccker-compose’ not found, did you mean

报错内容

安装docker-compose一直失败,一开始是用pip3 install docker-compose安装,但是安装结束还是继续报错

1
2
# 错误1:
sh: docker-compose: command not found
1
2
# 错误2:
Command 'doccker-compose' not found, did you mean

解决方法

1
sudo apt  install docker-compose

查看docker-compose版本

1
docker-compose --version

image-20220813171544113

pull access denied for wechatbot, repository does not exist or may require ‘docker login’: denied: requested access to the resource is denied

下载容器出错-login-20221210-628

我使用的是官方docker镜像仓库,可能导致错误的原因:

  • 需要先登录docker(没有账号先去docker注册一个)
  • 容器不存在