Docker使用中遇到的一些问题

常见报错

error1

push镜像到本地仓库时报错

 Error: Invalid registry endpoint https://10.10.3.67:5000/v2/: Get https://10.10.3.67:5000/v2/_ping: dial tcp 10.10.3.67:5000: connection refused. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 10.10.3.67:5000` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/10.10.3.67:5000/ca.crt 
或者
http: server gave HTTP response to HTTPS client
因为Docker从1.3.X之后,与docker registry交互默认使用的是https,然而此处搭建的私有仓库只提供http服务,所以当与私有仓库交互时就会报上面的错误。为了解决这个问题需要在启动docker server时增加启动参数为默认使用http访问。centos7下修改docker启动配置文件

[root@docker shell]# cat /usr/lib/systemd/system/docker.service 
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
ExecStart=/usr/bin/dockerd --insecure-registry 10.10.3.67:5000
再修改
[root@docker shell]# cat /etc/docker/daemon.json 

{
  "registry-mirrors": [
    "https://registry.docker-cn.com"
  ]
}
{
  "insecure-registry":["10.10.3.67:5000"]
}
然后重启服务
systemctl daemon-reload
systemctl restart docker

error2

[root@docker shell]# docker-compose up -d /etc/docker/registry/docker-compose.yml
ERROR: 
        Can't find a suitable configuration file in this directory or any
        parent. Are you in the right directory?
        Supported filenames: docker-compose.yml, docker-compose.yaml
切换到docker-compose.yaml所在目录下 启动成功

error3

ERROE:Cannot locate specified Dockerfile: Dockerfile
需要在docker-compose.yml里面指定Dockerfile路径
[root@docker data]# tree compose-test/
compose-test/
├── docker
│ ├── docker-compose.yml
│ ├── requirement.txt
│ └── web
│ └── Dockerfile
└── src
    └── app.py
在docker-compose.yml文件添加如下字段
app:
    build:
      context: web
      dockerfile: Dockerfile

error4

Docker默认的配置文件/etc/default/docker或者/etc/sysconfig/docker都不起作用,查看了一下/lib/systemd/system/docker.service文件,发现里面没有加载默认配置文件,一些配置不知道要怎么弄了~~~

解决办法是:

$ vi /lib/systemd/system/docker.service
#添加一行
$ EnvironmentFile=-/etc/default/docker
或者
$ EnvironmentFile=-/etc/sysconfig/docker
#-代表ignore error

#并修改
$ ExecStart=/usr/bin/docker daemon -H fd://
#改成
$ ExecStart=/usr/bin/docker daemon -H fd:// $DOCKER_OPTS

这样才能使用/etc/default/docker里定义的DOCKER_OPTS参数

$ systemctl daemon-reload 重载
$ sudo service docker restart

启动报错

[root@docker data]# systemctl status docker -l                                      
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2018-08-14 18:05:23 CST; 4min 31s ago
     Docs: https://docs.docker.com
  Process: 5580 ExecStart=/usr/bin/dockerd (code=exited, status=1/FAILURE)
 Main PID: 5580 (code=exited, status=1/FAILURE)

Aug 14 18:05:22 docker systemd[1]: Starting Docker Application Container Engine...
Aug 14 18:05:22 docker dockerd[5580]: time="2018-08-14T18:05:22.617552865+08:00" level=info msg="libcontainerd: new containerd process, pid: 5586"
Aug 14 18:05:23 docker dockerd[5580]: time="2018-08-14T18:05:23.623094222+08:00" level=error msg="[graphdriver] prior storage driver overlay2 failed: driver not supported"
Aug 14 18:05:23 docker dockerd[5580]: Error starting daemon: error initializing graphdriver: driver not supported
Aug 14 18:05:23 docker systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Aug 14 18:05:23 docker systemd[1]: Failed to start Docker Application Container Engine.
Aug 14 18:05:23 docker systemd[1]: Unit docker.service entered failed state.
Aug 14 18:05:23 docker systemd[1]: docker.service failed.
Warning: docker.service changed on disk. Run 'systemctl daemon-reload' to reload units.

root@docker data]# cat /etc/systemd/system/multi-user.target.wants/docker.service 
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target firewalld.service

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd --storage-driver=overlay2 --storage-opt overlay2.override_kernel_check=1  #更改此处,版本检查导致报错
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process

[Install]
WantedBy=multi-user.target

另一种启动报错

Aug 15 16:58:15 SoYi-Matchengine dockerd[23840]: time="2018-08-15T16:58:15.174852047+08:00" level=error msg="[graphdriver] prior storage driver overlay2 failed: driver not supported"
Aug 15 16:58:15 SoYi-Matchengine dockerd[23840]: Error starting daemon: error initializing graphdriver: driver not supported
Aug 15 16:58:15 SoYi-Matchengine systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE

应该是旧版本docker的仓库目录冲突导致

mv /var/lib/docker /var/lib/docker.old
然后启动docker

转载于:https://blog.51cto.com/dorebmoon/2334843

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值