docker-ce 安装

方法一(shell安装):
[root@iZuf6h0pjb0u8rhjhiqmf8Z ~]# cat 1-install-docker.sh
#!/bin/bash
set -e
yum install -y yum-utils device-mapper-persistent-data lvm2
yum makecache fast && yum -y install docker-ce
systemctl enable docker
systemctl start docker
#查看版本
docker --version
 
方法二(ansible安装):

[root@localhost docker]# cat 2-install-docker-ce.yml
---
- hosts: k
  remote_user: root
  tasks:
  - name: install docker-based
    yum:
      name: ['yum-utils', 'device-mapper-persistent-data', 'lvm2']
      state: present
  - name: config repo
    shell: yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    notify: yum-clean
  - name: install docker-ce
    yum:
       name: docker-ce
       state: present
  - name: enable and start docker
    service:
       name: docker
       enabled: yes
       state: started
  handlers:
    - name: yum-clean
      shell: yum clean all
      shell: yum makecache

编写playbook

执行playbook

 

版本查看

 

 
原文地址:https://www.cnblogs.com/szy2018/p/13770010.html