3
2

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.

Windows でも Ansible (on Docker)したい ~①Docker環境構築編~

Last updated at Posted at 2019-05-05

Ansibleを使って環境管理をしたいのですが、現在linux環境がない状態です。
そこでWindows上にDocker環境を構築してAnsibleを利用することにしました。
AnsibleもDockerも使ったことがなく、間違った点などもあるかもしれません。

参考

Docker について日本語のドキュメントがありましたので、基本的にそちらを参考にしています
http://docs.docker.jp/docker-for-windows/step_one.html

また、udemy「ゼロらはじめる Dockerによるアプリケーション実行環境構築」にて基礎的な部分の勉強をしました。
https://www.udemy.com/docker-k/

導入

動作環境

  • Windows 10 Pro 64bit
  • Intel Core i7-6700K
  • Docker Engine Community 18.09.2

Windows での Docker 利用

windowsでは以下の二通りの方法があります。
エディションなどでできる/できないがあるので自身の環境に合わせて実施してください。
私はDockerDesktop(windows)を利用できる環境だったので、そちらにしました

  • Docker Desktop (Windows)

    • 現在の公式推奨方式
    • Hyper-Vでの仮想化
      • Windows 10 Professional 64bit でないと利用できない
      • 後述のDockerToolsに対し高速なはず
    • これまではVirtualBoxとHyper-Vの共存ができなくて迷ったが、VirtualBox6.0から共存できるようになった
  • Docker Tools

    • 旧方式
    • VirtualBoxでの仮想化

手順

①Intel Virtualization Technology を有効にする

  • タスクマネージャのCPUのパフォーマンス画面にて、仮想化: 有効となっていれば、すでに設定済みです
    image.png
  • そうでなければBIOSの設定で有効化してください

②Windows に Hyper-Vをインストールする

③ Docker Desktop(Windows)をインストールする

  • DockerHubから、インストーラをダウンロードします
    ダウンロードにはDockerHubへのログインが必要なので、アカウントがない人は作成してください
    https://hub.docker.com/editions/community/docker-ce-desktop-windows
  • ダウンロードしたインストーラを実行します。
    特に複雑な手順はないので、言われるがままに進めれば大丈夫です

docker versionコマンドで動作を確認します

  • PowerShellを起動し、docker versionコマンドを実行して動作を確認します
    下記のような感じで表示されればOK
    image.png

初期設定

dockerhubへのログイン情報の設定

  • docker loginコマンドにて設定します
PS C:\Users\owner> docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: hogehoge
Password: 
Login Succeeded

つまづいた点

DNSがうまくいっていない

  • 下記のような形でうまく外部に出れていないよう
Step 3/3 : RUN apt-get update && apt-get install -y inetutils-ping
 ---> Running in f6ac8909c8ed
Err:1 http://deb.debian.org/debian stretch InRelease
  Temporary failure resolving 'deb.debian.org'
Err:2 http://security.debian.org/debian-security stretch/updates InRelease
  Temporary failure resolving 'security.debian.org'
Err:3 http://deb.debian.org/debian stretch-updates InRelease
  Temporary failure resolving 'deb.debian.org'
Reading package lists...
W: Failed to fetch http://deb.debian.org/debian/dists/stretch/InRelease  Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/InRelease  Temporary failure resolving 'security.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/InRelease  Temporary failure resolving 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
  • DNS Serverを8.8.8.8に設定

image.png

3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?