2022年4月13日 星期三

linux ubuntu 16.04 install docker

REF:https://docs.docker.com/engine/install/ubuntu/
sudo apt-get update
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
 echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
 sudo apt-get update
 sudo apt-get install docker-ce docker-ce-cli containerd.io


在ubuntu 1604上遇到了一些安裝的問題

dockerd[21814]: failed to start daemon: error initializing graphdriver: /var/lib/docker contains several valid graphdrivers: overlay2, aufs; Please cleanup or explicitly choose storage driver (-s <DRIVER>)


參考以下解決
https://stackoverflow.com/questions/45103803/not-able-to-start-docker-on-ubuntu-16-04-2-lts-error-initializing-graphdriver

17

I did some research and I found the answer. I was able to fix the issue by using the overlay2 as storage driver. I followed the below link for that: https://docs.docker.com/engine/userguide/storagedriver/overlayfs-driver/

I took the followins steps to fix the issue:

  1. Stop Docker.

    sudo systemctl stop docker
    
  2. Copy the contents of /var/lib/docker to a temporary location.

    cp -au /var/lib/docker /var/lib/docker.bk
    
  3. Edit /etc/docker/daemon.json. If it doesn't exist yet: create it. Assuming that the file was empty, add the following contents:

    {
      "storage-driver": "overlay2"
    }
    
  4. Start Docker.

    sudo systemctl start docker
    
  5. Verify that the daemon is using the overlay/overlay2 storage driver.

    sudo docker info
    

After this I was able to run docker container on my "16.04.2 LTS (Xenial Xerus)"

sudo docker run -dit ubuntu

ubuntu 更換 apt-get update 的台灣資料庫


 https://www.ubuntu-tw.org/modules/newbb/viewtopic.php?post_id=218626