はじめに
VagrantでDockerを構築するのが流行ってるらしい。
調べましたが、理由はよくわかりませんでした。
一つわかることは、MacやWindows上でDockerを構築したところで
結局仮想環境のLinux上でしか動いていないので
Vagrant上のDockerと変わらないということですね。
Vagrantのインストール
VirtulBoxとVagrantのインストールは、終わらせておいてください。
公式は、こちらです。
VirtulBox
Vagrant
Vagrantのディレクトリ作成
$ mkdir -p ~/Vagrant/ubuntu
$ cd ~/Vagrant/ubuntu
Vagrant公式からBoxダウンロード
Vagrant Cloud
official ubuntu 18.04
で検索したら発見したのでそれをインストール
Vagrant Ubuntu18.04
$ vagrant init ubuntu/bionic64
$ vagrant up
sshで接続
$ vagrant ssh
vagrantのバージョンの確認
vagrant@vagrant:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"
Docker install
LinuxのDockerインストールコマンドは、以下です。
vagrant@vagrant:~$ curl -fsSL https://get.docker.com/ | sh
Dockerのバージョンの確認
vagrant@vagrant:~$ docker --version
Docker version 18.06.1-ce, build e68fc7a
vagrant@vagrant:~$ docker version
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:24:51 2018
OS/Arch: linux/amd64
Experimental: false
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.38/version: dial unix /var/run/docker.sock: connect: permission denied
Hello World
vagrant@vagrant:~$ sudo docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
終わり
割とシンプルにインストールできちゃいます。
VagrantでDockerの環境構築流行っているそうなのでやってみました。
WordPressのKUSANAGI
をDockerで動かせるらしいのでまたやってみたいと思います。
仮想環境ぶっ壊しまくりましょう!!