Documents

Install/Upgrade Docker

Install Docker

  1. Install the Docker in CentOS 7.x

    # install docker in centos 7.x
    user $ sudo -i # access by root
    root $ curl -fsSL <https://get.docker.com> -o get-docker.sh
    root $ sh get-docker.sh
    root $ usermod -aG docker user
    root $ usermod -aG docker usersu
    root $ systemctl restart docker # better way
    
    # root $ service docker restart
  2. Change the root dir of Docker

    1. Check current root dir

      user $ systemctl status docker
      ● docker.service - Docker Application Container Engine
         Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
         Active: active (running) since 목 2019-03-28 16:35:40 KST; 19h ago
           Docs: https://docs.docker.com
       Main PID: 142103 (dockerd)
          Tasks: 24
         Memory: 34.5M
         CGroup: /system.slice/docker.service
                 ├─142103 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
                 └─155121 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-ip 172.17.0.2 -container-port 9000
    2. Create new root dir

      user $ mkdir -p ~/apps/docker_root
      root $ vi /usr/lib/systemd/system/docker.service
    3. Update root dir path

      docker.service file
      [Service]
      ExecStart=/usr/bin/dockerd -g /home/user/apps/docker_root -H unix://
    4. Restart

      root $ systemctl daemon-reload
      root $ systemctl restart docker
      
      user $ docker info | grep Root
      Docker Root Dir: /var/lib/docker

Upgrade Docker

  1. Check system environment and versions

    $ cat /etc/centos-release
    CentOS Linux release 7.4.1708 (Core)
    
    $ uname -a
    Linux host-name 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    
    $ docker --version
    Docker version 18.09.0, build 4d60db4
    
    # Check all docker versions
    $ pid_dock=$(ps -ef | awk '$8~/(^|\/)dockerd($|-ce$|-current$)/ {print $2}'); if [ $pid_dock > 0 ]; then   docker_exe=$(ls -l /proc/$pid_dock/exe | awk -F'-> ' '{print $2}');   $docker_exe -v | awk '{print $3}' | sed 's/,//g'; fi;
    19.03.1
  2. Stop docker engine

    sudo $ systemctl stop docker
  3. TODO

    # dwnload rpm file
    $ wget https://download.docker.com/linux/centos/7/x86_64/...
    # check installed docker
    $ yum list docker-ce --showduplicates | sort -r
    # upgrade docker
    $ sudo yum upgrade docker-ce docker-ce-cli
  4. Start docker engine

    sudo $ systemctl restart docker