Docker 问题积累

1. 使用Dockerfile构建镜像时报错

ERROR: Failed to create lib/ld-musl-x86_64.so.1: No space left on device ERROR: musl-1.1.15-r6: No space left on device

Dockerfile内容如下:


FROM alpine 
RUN apk update && apk upgrade 
RUN apk add python 
RUN apk add curl 
RUN apk add libsodium 
RUN curl "https://bootstrap.pypa.io/get-pip.py" -o "/tmp/get-pip.py" 
RUN python "/tmp/get-pip.py" 
RUN pip install --upgrade pip 
RUN pip install shadowsocks 
ENV SS_PASSWORD 123456 
ENV SS_METHOD chacha20
COPY ss.cfg /tmp/ 
ENTRYPOINT /usr/bin/ssserver -k ${SS_PASSWORD} -m ${SS_METHOD} 
EXPOSE 60000

经查证排除磁盘空间不足的问题。
这个问题是apk的一个bug。
参考连接:
https://github.com/gliderlabs/docker-alpine/issues/231

2. Docker时区问题
容器镜像中一般默认时区是UTC,改为CST可以如下进行:
(1)方法一:
起容器时加上 -v /etc/loaltime:/etc/loaltime:ro #共享宿主机时区

(2) 方法二


   cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 
 

3. 启动Docker进程失败–Centos7.X

报错如下:

[root@centos72 ~]# systemctl start docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

ifconfig查看时没有生成docker0网桥
查看状态报错信息如下:

[root@centos72 ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2017-03-06 10:57:41 CST; 10s ago
     Docs: http://docs.docker.com
  Process: 48584 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current $OPTIONS $DOCKER_SE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY (code=exited, status=1/FAILURE)
 Main PID: 48584 (code=exited, status=1/FAILURE)

Mar 06 10:57:41 centos72.novalocal dockerd-current[48584]: time="2017-03-06T10:57:41.033103724+08:00" level=warning msg="Docker could not enable SELinux on the host system"
Mar 06 10:57:41 centos72.novalocal dockerd-current[48584]: time="2017-03-06T10:57:41.038337006+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Mar 06 10:57:41 centos72.novalocal dockerd-current[48584]: time="2017-03-06T10:57:41.038541983+08:00" level=warning msg="mountpoint for pids not found"
Mar 06 10:57:41 centos72.novalocal dockerd-current[48584]: time="2017-03-06T10:57:41.038684660+08:00" level=info msg="Loading containers: start."
Mar 06 10:57:41 centos72.novalocal dockerd-current[48584]: time="2017-03-06T10:57:41.043425594+08:00" level=info msg="Firewalld running: false"
Mar 06 10:57:41 centos72.novalocal dockerd-current[48584]: time="2017-03-06T10:57:41.111389603+08:00" level=fatal msg="Error starting daemon: Error initializing network controller: Error creating default \"bridge\" network: failed to parse pool request for address spa
Mar 06 10:57:41 centos72.novalocal systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Mar 06 10:57:41 centos72.novalocal systemd[1]: Failed to start Docker Application Container Engine.
Mar 06 10:57:41 centos72.novalocal systemd[1]: Unit docker.service entered failed state.
Mar 06 10:57:41 centos72.novalocal systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
You have new mail in /var/spool/mail/root

关键内容:

level=fatal msg=”Error starting daemon: Error initializing network controller: Error creating default \”bridge\” network: failed to parse pool request for address spa

解决:
在Docker配置文件/etc/sysconfig/docker “OPTIONS”中加入:–bip=172.17.42.1/16, 如下:

# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --bip=172.17.42.1/16'

systemctl start docker即可

4. docker启动失败

[root@localhost ~]# systemctl status docker.service -l
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sat 2017-03-18 01:10:06 PDT; 2min 53s ago
     Docs: http://docs.docker.com
  Process: 3494 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY (code=exited, status=1/FAILURE)
 Main PID: 3494 (code=exited, status=1/FAILURE)

Mar 18 01:10:04 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
Mar 18 01:10:04 localhost.localdomain dockerd-current[3494]: time="2017-03-18T01:10:04.976205048-07:00" level=info msg="libcontainerd: new containerd process, pid: 3500"
Mar 18 01:10:06 localhost.localdomain dockerd-current[3494]: time="2017-03-18T01:10:06.011206081-07:00" level=warning msg="devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docker` to refer to dm.thinpooldev section."
Mar 18 01:10:06 localhost.localdomain dockerd-current[3494]: time="2017-03-18T01:10:06.022012288-07:00" level=warning msg="devmapper: Base device already exists and has filesystem xfs on it. User specified filesystem  will be ignored."
Mar 18 01:10:06 localhost.localdomain dockerd-current[3494]: time="2017-03-18T01:10:06.027998073-07:00" level=fatal msg="Error starting daemon: error initializing graphdriver: \"/var/lib/docker\" contains several valid graphdrivers: devicemapper, overlay; Please cleanup or explicitly choose storage driver (-s <DRIVER>)"
Mar 18 01:10:06 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Mar 18 01:10:06 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Mar 18 01:10:06 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
Mar 18 01:10:06 localhost.localdomain systemd[1]: docker.service failed.

关键内容:
level=fatal msg=”Error starting daemon: error initializing graphdriver: \”/var/lib/docker\” contains several valid graphdrivers: devicemapper, overlay; Please cleanup or explicitly choose storage driver (-s )”

解决:
删除/var/lib/docker/下面的数据,重启docker服务即可,重启后/var/lib/docker/里面的数据会重新生成。

rm -rf /var/lib/docker/*
systemctl start docker

5. Docker启动失败–ubuntu
启动docker时报错如下:


Error initializing network controller: list bridge addresses failed: no available network

解决:


apt-get install bridge-utils
brctl addbr docker0
ifconfig docker0 172.17.42.1 
echo 'DOCKER_OPTS="b=docker0"' >> /etc/default/docker
systemctl docker start

6. docker pull镜像失败
具体报错如下:

[root@localhost ~]# docker pull hub.c.163.com/xxxxxx/test:python
Trying to pull repository hub.c.163.com/xxxxxx/test ... 
Pulling repository hub.c.163.com/xxxxxx/test
Error: image xxxxxx/test not found

如果镜像存在且路径正确,一般是未登陆认证的原因,docker login hub.c.163.com 后可以解决。

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010472499/article/details/54929678
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭