LoginSignup
1
1

More than 5 years have passed since last update.

Windows10 - Vagrant - CentOS7 - docker, docker-compose 環境構築

Last updated at Posted at 2019-04-15

update 2019.04.15

Windows10 : VirtualBox , Git , Vagrant

(Git Bash : Windows)

$ git --version
git version 2.21.0.windows.1

$ vagrant --version
Vagrant 2.2.4

Vagrant : CentOS7

(Git Bash : Windows)

$ cd /c/vagrant/centos7
$ vagrant init centos/7
$ vagrant up
$ vagrant ssh
(Git Bash : Vagrant - CentOS7)

$ cat /etc/centos-release
---
CentOS Linux release 7.6.1810 (Core)
---

$ sudo yum -y update

Vagrantfile : private network (hostonly)

  • host(windows10)から、アクセス用
config.vm.network "private_network", ip: "192.168.33.10"

Vagrantfile : synced folder

  • VirtualBox Guest Additions インストール
$ vagrant plugin install vagrant-vbguest
$ vagrant vbguest
$ vagrant reload
  • host(windows10)で、ファイル編集用
config.vm.synced_folder "./docker", "/docker", owner: "vagrant", group: "vagrant", type: "virtualbox", :mount_options => ['dmode=755', 'fmode=644']

※ DNS解決できない場合...

CentOS7 : docker , docker-compose

$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
$ sudo yum makecache fast
$ sudo yum install -y docker-ce

$ sudo systemctl start docker
$ sudo systemctl status docker
$ sudo systemctl enable docker

$ sudo usermod -aG docker vagrant
※ 再ログイン後、反映
$ groups
---
vagrant docker
---

$ docker --version
---
Docker version 18.09.5, build e8ff056
---
  • docker hello world テスト
$ docker run hello-world
---
...
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
---

$ docker images
---
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              fce289e99eb9        3 months ago        1.84kB
---

CentOS7 : docker-compose

$ sudo curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
$ docker-compose --version
---
docker-compose version 1.24.0, build 0aa59064
---
  • docker-compose hello world テスト
$ mkdir -p /docker/helloworld
$ cd /docker/helloworld
$ vi docker-compose.yml
---
version: "3"
services:
  hello:
    image: hello-world
---

$ docker-compose run
---
Creating network "helloworld_default" with the default driver
Creating helloworld_hello_1 ... done
Attaching to helloworld_hello_1
hello_1  |
hello_1  | Hello from Docker!
hello_1  | This message shows that your installation appears to be working correctly.
hello_1  |
hello_1  | To generate this message, Docker took the following steps:
hello_1  |  1. The Docker client contacted the Docker daemon.
hello_1  |  2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
hello_1  |     (amd64)
hello_1  |  3. The Docker daemon created a new container from that image which runs the
hello_1  |     executable that produces the output you are currently reading.
hello_1  |  4. The Docker daemon streamed that output to the Docker client, which sent it
hello_1  |     to your terminal.
hello_1  |
hello_1  | To try something more ambitious, you can run an Ubuntu container with:
hello_1  |  $ docker run -it ubuntu bash
hello_1  |
hello_1  | Share images, automate workflows, and more with a free Docker ID:
hello_1  |  https://hub.docker.com/
hello_1  |
hello_1  | For more examples and ideas, visit:
hello_1  |  https://docs.docker.com/get-started/
hello_1  |
helloworld_hello_1 exited with code 0
---
1
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
1
1