概要
- ちまたで話題のDockerをマスタすべく、ローカルWindowsPCで動作検証しました。詳しくないので、ひとつずつ、じっくりと・・・。
- 検証の結果、イントラネット内のクリティカルではない「WWW Server」として複数公開するケースなどで、実用できるのではないかと思っています。
- ひとつずつ結果をまとめていこうと思います。
セットアップ手順
ベースとなるホストOS環境は、ほとんどzabbix検証のときと同じ環境です。
- 検証環境
- PC - Windows10
- vagrant 1.7.4
- VirtualBox 5.0
1. Vangrant構築
> vagrant box add centOS71min https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box > mkdir C:\vagrant\hosts\centos71_docker > cd C:\vagrant\hosts\centos71_docker > vagrant init centOS71min A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant.
仮想マシンのIPアドレス設定
- 作成されたVagrantfileを編集します。メモ帳などで開き、1行のコメント行を有効にします。
# using a specific IP. # config.vm.network "private_network", ip: "192.168.33.10" <<< 有効化(#を削除する)
起動
C:\vagrant\hosts\centos71_docker>vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'centOS71min'... ==> default: Matching MAC address for NAT networking... ==> default: Setting the name of the VM: centos71_docker_default_1445140865540_31304 ==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: hostonly ==> default: Forwarding ports... default: 22 => 2222 (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection timeout. Retrying... default: Warning: Connection timeout. Retrying... default: default: Vagrant insecure key detected. Vagrant will automatically replace default: this with a newly generated keypair for better security. default: default: Inserting generated public key within guest... default: Removing insecure key from the guest if it's present... default: Key inserted! Disconnecting and reconnecting using new SSH key... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... default: The guest additions on this VM do not match the installed version of default: VirtualBox! In most cases this is fine, but in rare cases it can default: prevent things such as shared folders from working properly. If you see default: shared folder errors, please make sure the guest additions within the default: virtual machine match the version of VirtualBox you have installed on default: your host and reload your VM. default: default: Guest Additions Version: 4.3.26 default: VirtualBox Version: 5.0 ==> default: Configuring and enabling network interfaces... ==> default: Mounting shared folders... default: /vagrant => C:/vagrant/hosts/centos71_docker C:\vagrant\hosts\centos71_docker>
2. Server接続(192.168.33.10)
- Tera Termを使ってSSHログインします。
host: 192.168.33.10 port: 22 user: vagrant pass: vagrant
3. タイムゾーン設定・確認
# timedatectl set-timezone Asia/Tokyo # timedatectl Local time: Sun 2015-10-18 13:02:55 JST Universal time: Sun 2015-10-18 04:02:55 UTC RTC time: Sun 2015-10-18 04:02:55 Timezone: Asia/Tokyo (JST, +0900) NTP enabled: n/a NTP synchronized: no RTC in local TZ: no DST active: n/a
4. 日本語化
# yum -y install ibus-kkc vlgothic-* : Installed: ibus-kkc.x86_64 0:1.5.18-5.el7 vlgothic-fonts.noarch 0:20130607-2.el7 vlgothic-p-fonts.noarch 0:20130607-2.el7 : # localectl set-locale LANG=ja_JP.UTF-8 # source /etc/locale.conf # echo $LANG ja_JP.UTF-8
5. Sudo設定
- root権限をvagrantユーザーに全て与えます(毎回要求されるパスワード認証は無し)。
# visudo : vagrant ALL=(ALL) NOPASSWD:ALL <<< 最終行に追記する。(119行目)
6.各種パッケージのアップデート/vimのインストール
$ sudo yum -y update $ sudo yum -y install vim
7.SELinuxのdisabled
$ sudo vim /etc/selinux/config
- すでに「SELINUX=disabled」になっていました。
8. ファイアウォール無効化
検証用のため、無効にしました。
$ systemctl list-unit-files | grep firewall firewalld.service enabled # sudo systemctl disable firewalld.service rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service' rm '/etc/systemd/system/basic.target.wants/firewalld.service' $ systemctl list-unit-files | grep firewall firewalld.service disabled
9. Dockerインストール
$ sudo yum -y install docker : インストール: docker.x86_64 0:1.7.1-115.el7 依存性関連をインストールしました: audit-libs-python.x86_64 0:2.4.1-5.el7 checkpolicy.x86_64 0:2.1.12-6.el7 docker-selinux.x86_64 0:1.7.1-115.el7 libcgroup.x86_64 0:0.41-8.el7 libsemanage-python.x86_64 0:2.1.10-16.el7 policycoreutils-python.x86_64 0:2.2.5-15.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.7-46.el7 完了しました! $ docker -v Docker version 1.7.1, build 446ad9b/1.7.1
10. Docker自動起動設定
$ sudo systemctl enable docker.service
これで、Dockerを試せる環境が整いました。これをホストOSとして、コンテナを構築しようと思います!