LoginSignup
6
5

More than 5 years have passed since last update.

まっさらの状態のwindowsでdockerを始める手順

Last updated at Posted at 2018-05-31

Docker for Windows は Windows10 Pro でなければ使えません。
Windows8 はもちろん、Windows10 Home でも使用することはできません。
こうした場合、仮想マシンとして Linux を建てて、そこに Docker をインストールする必要があります。

以下、手順を説明します。

まずはもろもろをインストールします。
インストーラーを下記URLよりダウンロードしてインストールします。

■ Virtual Box(仮想化ソフト)
http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html?ssSourceSiteId=otnjp

■ Vagrant(仮想化ソフト)
https://www.vagrantup.com/downloads.html

■ git(分散型バージョン管理システム)
https://git-scm.com/download/win

■ Visual Studio Code(テキストエディタ)
https://code.visualstudio.com/download

Visual Studio Codeの 設定をします。
デフォルトのターミナルを「コマンドプロンプト」から「git bash」に変更します。
[ファイル] > [基本設定] > [設定] > [ユーザー設定] に設定を追加します。

{
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
}

Visual Studio Codeにターミナルを表示させます。
[表示] > [統合ターミナル] > [ターミナル] で表示させます。

ターミナルで作業をしていきます。

# 作業フォルダの作成
$ mkdir ~/Documents/DockerProject

# 作業フォルダに移動
$ cd ~/Documents/DockerProject

# アドオンのインストール
$ vagrant plugin install vagrant-vbguest

# Vagrantfileの作成
$ vagrant init ubuntu/xenial64

作成されたVagrantfileを編集します。
46行目あたりです。

Vagrantfile
- # config.vm.synced_folder "../data", "/vagrant_data"
+ config.vm.synced_folder ".", "/vagrant", type:"virtualbox"

編集をしたらターミナルでの作業に戻ります。

# 仮想マシン起動(初回は時間が掛かります)
$ vagrant up

# 仮想マシンにログイン
$ vagrant ssh

# 仮想マシンにgitのインストール
$ sudo apt-get update
$ sudo apt-get install -y apt-file
$ sudo apt-file update
$ sudo apt-file search add-apt-repository
$ sudo apt-get install -y software-properties-common
$ sudo add-apt-repository -y ppa:git-core/ppa
$ sudo apt-get update
$ sudo apt-get upgrade -y
$ sudo apt-get install -y git

# 仮想マシンにdockerのインストール
$ sudo apt-get remove docker docker-engine http://docker.io 
$ sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu  $(lsb_release -cs) stable"
$ sudo apt-get update
$ sudo apt-get install -y docker-ce
$ sudo docker run hello-world
$ docker -v

# 仮想マシンにdocker-composeのインストール
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.12.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
$ docker-compose -v

windowsでdockerが使えるようになりました。

参考
https://docs.docker.com/compose/install/

6
5
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
6
5