Docker报错

  1. 启动报错

    1
    2
    3
    4
    5
    6
    7
    8
    [root@VM-0-14-centos docker]# docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    0e03bdcc26d7: Pull complete
    Digest: sha256:31b9c7d48790f0d8c50ab433d9c3b7e17666d6993084c002c2ff1ca09b96391d
    Status: Downloaded newer image for hello-world:latest
    runc: symbol lookup error: runc: undefined symbol: seccomp_api_get
    docker: Error response from daemon: cannot start a stopped process: unknown.

    解决方法: 更新libseccomp库, seccomp_api_set定义在2.4以上版本中

    yum update libseccomp

  2. Docker挂载主机目录Docker访问出现cannot open directory: Permission denied

    解决方法: 在挂载目录后多加一个--privileged=true参数

  3. 有时候输入socker的命令会报:

    1
    Cannot connect to the Docker daemon at unix:///var/run/docker.sock.

    原因: 上一次没有正常退出docker

    解决方法: sudo service docker restartsudo systemctl start docker

    (mac的话查看有没有启动,状态栏小鲸鱼有没有)

  4. 运行centos8,无法执行systemctl

    System has not been booted with systemd as init system (PID 1). Can't operat

    解决方法:docker run --privileged -itd centos-yiqing:1.1 /usr/sbin/init

    之后就可以使用docker exec -it xxx /bin/bash

  5. 通过apt-get安装yum

    在使用Docker镜像文件时,某些镜像往往并没有安装yum命令,此时就无法通过yum安装其他软件。那么此时应该如何进行yum命令的安装呢?

    我们可以通过apt-get来先将yum命令进行安装,执行如下命令:

    apt-get install yum

    但此时通常情况下并不会顺利安装,如果控制台输出如下信息:

    1
    2
    3
    4
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package yum

    则说明安装出现问题,需要更新一下APT库。

    更新APT库需要执行如下命令:

    1
    2
    apt-get update
    apt-get upgrade

    然后执行apt-get install yum即可

    如果yum安装出现

    There are no enabled repos

    这是因为yum没有配置源

    1
    2
    3
    4
    5
    6
    7
    删除
    rm -f /etc/yum.repos.d/CentOS-Base.repo
    配置成阿里的源
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

    清除缓存
    yum clean all