美文网首页
Ubuntu14下无法运行Docker重装过程

Ubuntu14下无法运行Docker重装过程

作者: 何约什 | 来源:发表于2018-12-23 14:57 被阅读19次

    碰到的问题

    我的主机操作系统安装的是Ubuntu 14.04.1 LTS,内核版本为:3.8.0-21-generic

    在运行docker命令或者dockerd时,总是直接core掉。

    重新安装docker

    删除旧版本的docker

    sudo apt-get purge -y docker-engine docker docker.io docker-ce  
    sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce  
    

    修改apt source:(/etc/apt/sources.list)

    deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
    

    重新安装docker

    sudo apt-get update 
    apt-get install docker
    

    运行dockerd,会发现报以下错误:

    You are running linux kernel version 3.8.0-21-generic, which might be unstable running docker. Please upgrade your kernel to 3.10.0.
    

    升级内核

    wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.10-saucy/linux-headers-3.10.10-031010-generic_3.10.10-031010.201308291422_amd64.deb
    wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.10-saucy/linux-headers-3.10.10-031010_3.10.10-031010.201308291422_all.deb
    wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.10-saucy/linux-image-3.10.10-031010-generic_3.10.10-031010.201308291422_amd64.deb
    sudo dpkg -i linux-headers-3.10.10-*.deb linux-image-3.10.10*.deb
    
    

    重启操作系统,运行dockerd

    /usr/local/docker/dockerd --data-root=/data1/docker
    
    ERRO[2018-12-23T13:25:08.192898199+08:00] Handler for POST /v1.37/containers/965bfd8d50f79cc115aad1cd87bc3449e79033964f26acd8c4884fbbbae6b2eb/start returned error: Could not check if docker-default AppArmor profile was loaded: open /sys/kernel/security/apparmor/profiles: no such file or directory 
    

    经查,可能原因是我在升级内核时,有些问题:

    open /sys/kernel/security/apparmor/profiles: no such file or directory 
    可能原因:
    
    Not all patches were applied or userspace/kernel mismatch
    

    取消apparmor

    $ sudo mkdir -p /etc/default/grub.d
    $ echo 'GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT apparmor=0"' \
      | sudo tee /etc/default/grub.d/apparmor.cfg
    $ sudo update-grub
    $ sudo reboot
    

    再次启动dockerd,再次运行hello-world容器成功了。

    root@herrypc:~# docker run hello-world
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (amd64)
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
    
    To try something more ambitious, you can run an Ubuntu container with:
     $ docker run -it ubuntu bash
    
    Share images, automate workflows, and more with a free Docker ID:
     https://hub.docker.com/
    
    For more examples and ideas, visit:
     https://docs.docker.com/get-started/
    
    root@herrypc:~# 
    

    相关文章

      网友评论

          本文标题:Ubuntu14下无法运行Docker重装过程

          本文链接:https://www.haomeiwen.com/subject/oshnkqtx.html