Docker-ce+Ubuntu 16.04環境配置

ubuntu 16.04 install & configure docker-ce

for ubuntu 14.04, do follows first to install extra packages:
$ sudo apt-get install \
    linux-image-extra-$(uname -r) \
    linux-image-extra-virtual

step one: Set up the repository (no way we have to choose the aliyun docker source here, you know what i mean)
1. Update the apt package index:
    $ sudo apt-get update
2. Install packages to allow apt to use a repository over HTTPS:
    $ sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
        software-properties-common
3. Add Docker’s official GPG key:
    $ curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
4. set up the stable repository:
    $ sudo add-apt-repository \
       "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu \
       $(lsb_release -cs) \
       stable"

step two: Install Docker ce
1. Update the apt package index:
    $ sudo apt-get update
2. Install the latest version of Docker CE:
    $ sudo apt-get install docker-ce
3. Verify that Docker CE is installed correctly by running the hello-world image.
    $ sudo docker run hello-world

step three: Manage Docker as a non-root user
1. Create the docker group:
    $ sudo groupadd docker
2. Add your user to the docker group:
    $ sudo usermod -aG docker $USER
3. Log out and log back in so that your group membership is re-evaluated.
4. Verify that you can run docker commands without sudo:
    $ docker run hello-world

step four: Change Docker root dir
caution: In oder to save space on root partition, here we change the path from /var/lib/docker to $(path).
        if do not split / and home on different hard disk partition when install os, just skip this step
1. add a json file for docker daemon configuration
$ sudo mkdir -p /etc/docker
$ sudo tee -a /etc/docker/daemon.json <<-'EOF'
{
  "graph": "/home/xxxx/docker"
}
EOF
3. reload the configuration: (if you are ubuntu 14.04, just sudo reboot and skip 3 & 4)
    $ systemctl daemon-reload
4. restart the docker daemon
    $ systemctl restart docker.service
5. verify the result:
    $ docker info | grep Root
   you will see follows:
    Docker Root Dir: /home/xxxx/docker

step five: Configure Aliyun Docker accelerator
caution: here take my own applied accelerator url as an example, you can apply a new one on https://cr.console.aliyun.com/#/accelerator
1. add to the json file:
$ sudo tee -a /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]
}
EOF
2. reload the configuration:
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

step six: Install Nvidia-docker and corresponding Plugin
1. install nvidia-modprobe first:
    $ sudo apt install nvidia-modprobe
2. Install nvidia-docker and nvidia-docker-plugin:
    $ sudo wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
    $ sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb

Warning:  
extra step: Uninstall docker ce
1. Uninstall the Docker CE package:
    $ sudo apt-get purge docker-ce
2. To delete all images, containers, and volumes:
    $ sudo rm -rf /var/lib/docker
   if step four is operated, than change the /var/lib/docker to your specified path

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章