0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ubuntuのdocker-engine12とdocker-compose1.8をdocker17.03.0-ceとdocker-compose1.11.2に更新したメモ

Last updated at Posted at 2017-03-17

環境

  • windows10
  • vagrant1.8
  • virtualbox5.1
  • ubuntu16.04(仮想環境)

既存の環境のアンインストール

sudo apt-get remove docker docker-engine
sudo rm /usr/local/bin/docker-compose

インストール

公式の手順に従ったらすんなりと出来た。(docker-ce , docker-compose)
ansibleのファイルに書いたので、以下を参照。

---
# docker 
# Installation ubuntu 
# https://docs.docker.com/engine/installation/linux/ubuntulinux/
  
  - name: dockerがインストールされていなければインストール
    command: docker
    register: result
    ignore_errors: True
    check_mode: no
    failed_when: no
    changed_when: result.rc != 0
  
  - block:
    # 環境設定
    - name: step0.5
      shell: echo 127.0.1.1 $(hostname) >> /etc/hosts
    - name: step1
      shell: export DEBIAN_FRONTEND=noninteractive

     # 一部環境では以下を実行しないとエラーが発生
     # aptが起動していて次のタスクが立ち上がらないエラー
    - name: step1.5
      shell: killall -KILL apt.systemd.daily
      ignore_errors: True

    # ここから公式のインストール手順
    - name: step2
      apt: name={{item}} state=present update_cache=yes
      with_items:
        - apt-transport-https 
        - ca-certificates 
        - curl
        - software-properties-common

    - name: step3
      shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

    - name: step4
      shell: apt-key fingerprint 0EBFCD88 warn=no

    - name: step5.1
      shell: add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" warn=no

    - name: step5.2
      shell: apt-get update warn=no

    - name: step6
      apt: name={{item}} state=present update_cache=yes
      with_items:
        - docker-ce

    - name: step6.2
      shell: apt-cache madison docker-ce warn=no

    - name: step8
      shell: gpasswd -a vagrant docker
    when: result|failed
  
  - name: test docker-composeが インストールされていなければインストール
    command: docker-compose --version
    register: result
    ignore_errors: True
    check_mode: no
    failed_when: no
    changed_when: result.rc != 0
  
  - block:
    - name: step1
      shell: curl -L "https://github.com/docker/compose/releases/download/1.11.2/docker-compose-$(uname -s)-$(uname -m)" > /usr/local/bin/docker-compose &&  chmod +x /usr/local/bin/docker-compose warn=no

    when: result|failed

メモ。更新前のansibleファイル

忘備録

---
# docker 
# Installation ubuntu 
# https://docs.docker.com/engine/installation/linux/ubuntulinux/
  
  - name: dockerがインストールされていなければインストール
    command: docker
    register: result
    ignore_errors: True
    check_mode: no
    failed_when: no
    changed_when: result.rc != 0
  
  - block:
    - name: step0.5
      shell: echo 127.0.1.1 $(hostname) >> /etc/hosts

# http://qiita.com/udzura/items/576c2c782adb241070bc
# https://gist.github.com/indykish/a6facea4748dc578abbaf2b09065ead5
    - name: step1
      shell: export DEBIAN_FRONTEND=noninteractive

# 一部環境では以下を実行しないとエラーが発生
# aptが起動していて次のタスクが立ち上がらないエラー
    - name: step1.5
      shell: killall -KILL apt.systemd.daily
      ignore_errors: True

    - name: step2
      apt: name={{item}} state=present update_cache=yes
      with_items:
        - apt-transport-https
        - ca-certificates

    - name: step3.1
      shell: apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
      register: res3
      ignore_errors: True

# gpgエラーでstep3が失敗することがある。しかしこれでもstep5.1で失敗。
#  - name: step3.1.1
#    shell: wget -q -O - https://get.docker.com/gpg | apt-key add -
#    when: res3|failed
# 3.1.1が失敗するのでこちらの書き方に変更
    - name: step3.1.2
      shell: wget -qO- https://get.docker.com/ | sh
      when: res3|failed

    - name: step4
      shell: echo "deb https://apt.dockerproject.org/repo ubuntu-xenial experimental" > /etc/apt/sources.list.d/docker.list

    - name: step5.1
      shell: apt update

# apt モジュールを使えと警告がでるのをカット
    - name: step5.2
      shell: apt-get purge lxc-docker warn=no

    - name: step5.3
      shell: apt-cache policy docker-engine

# apt モジュールを使えと警告がでるのをカット
    - name: step6
      shell: apt-get install -y linux-image-extra-$(uname -r) warn=no

    - name: step7
      apt: name={{item}} state=present update_cache=yes
      with_items:
        - docker-engine

    - name: step8
      shell: gpasswd -a vagrant docker
    when: result|failed

  
  - name: test docker-composeが インストールされていなければインストール
    command: docker-compose --version
    register: result
    ignore_errors: True
    check_mode: no
    failed_when: no
    changed_when: result.rc != 0
  
  - block:
    - name: step1
      shell: curl -L "https://github.com/docker/compose/releases/download/1.8.1/docker-compose-$(uname -s)-$(uname -m)" > /usr/local/bin/docker-compose &&  chmod +x /usr/local/bin/docker-compose warn=no

    when: result|failed

参考

docker-ce ubuntu install
docker-compose ubuntu install

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?