Instalación de Docker

Shell

export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y apt-transport-https ca-certificates wget software-properties-common curl
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
apt-get update
apt-get install -y docker-ce docker-compose
usermod -aG docker $USER    # Optional to include user docker management, if not, just root

Ansible

- hosts: all
  become: true

  tasks:
    - name: ensure repository key is installed
      apt_key:
        id: "58118E89F3A912897C070ADBF76221572C52609D"
        keyserver: "hkp://p80.pool.sks-keyservers.net:80"
        state: present

    - name: ensure docker registry is available
      # For Ubuntu 16.04 LTS
      apt_repository: repo='deb https://apt.dockerproject.org/repo ubuntu-xenial main' state=present

    - name: ensure docker and dependencies are installed
      apt: name={{ item }} update_cache=yes
      with_items:
        - docker-engine
        - docker-compose

Shell

yum --add-repo

#!/bin/bash
if [[ ! $(which docker) ]]; then
  yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  yum install -y docker-ce
  systemctl enable docker && systemctl start docker
fi
if [[ ! $(which docker-compose) ]]; then
  yum install -y epel-release
  yum install -y yum-utils device-mapper-persistent-data lvm2 python-pip vim git
  yum upgrade -y python*
  pip install docker-compose
fi

get.docker.com

#!/bin/bash
if [[ ! $(which docker) ]]; then
  curl -fsSL https://get.docker.com/ | sh
  systemctl enable docker && systemctl start docker
fi

if [[ ! $(which docker-compose) ]]; then
	yum install -y epel-release
	yum upgrade -y python*
	yum install -y python-pip git vim
	pip install --upgrade pip
	pip install docker-compose
fi
usermod -a -G docker vagrant

User-Data: cloud-init

runcmd:
  - yum install -y epel-release
  - yum install -y docker
  - yum install -y python-pip
  - pip install docker-compose
  - systemctl enable docker && systemctl start docker