특정 물리장치에 VM을 여러개 뛰우고, Docker 머신을 여러개 뛰우는 방법을 소개하고자한다.
하나의 도커에 여러개의 컨테이너를 관리하는것도 어려운데, 이렇게 하는 이유는 이 단계를 뛰어넘어
여러개의 N개의 도커 N개의 컨테이너를 어떻게 잘 관리할것인가? 도커 오케스트라 툴을 시도해보기 위해서이다.
준비물:
Virtual Box 설치
Vagrant 설치
OS는 도커전용 OS인 가벼운 CoreOS를 선택하였다.
우선, 물리장치인 1PC의 호스트 전용 네트워크를 설정한다. 이 네트워크 기반으로 여러개의
VM을 뛰우기위함이다.
호스트 전용 네트워크 설정
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vbguest.auto_update = false
config.vm.box = "kleesc/coreos"
config.vm.hostname = "docker2"
config.vm.network "private_network", ip: "192.168.56.202"
config.vm.synced_folder "/media/psmon/DataB/docker_data2", "/vagrant_data",
type: "nfs",
linux__nfs_options: ['rw','no_subtree_check','all_squash','async']
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
vb.memory = "2048"
end
#
# View the documentation for the provider you are using for more
# information on available options.
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
end
VM을 생성하는 스크립트이며, 파일형태로 VM의 생성 정보를 유지하면 된다.
각각의 디렉토리에 Vagrantfile을 생성하여 3대의 VM을 목록을 작성한예이다.
docker1/Vagrantfile
docker2/Vagrantfile
docker3/Vagrantfile
vagrant 명령들
vagrant up : vm을 구동시킨다.
vagrant ssh : ssh접속
vagrant halt : vm 중지
vagrant reload : vm 재시작
vagrant destroy : vm 삭제
3대의 vm을 가진 docker 가 순식간에 각각의 프라이빗 네트워크를 가진채 생성이 되었다.
Vagrant for Multi Docker
특정 물리장치에 VM을 여러개 뛰우고, Docker 머신을 여러개 뛰우는 방법을 소개하고자한다.
하나의 도커에 여러개의 컨테이너를 관리하는것도 어려운데, 이렇게 하는 이유는 이 단계를 뛰어넘어
여러개의 N개의 도커 N개의 컨테이너를 어떻게 잘 관리할것인가? 도커 오케스트라 툴을 시도해보기 위해서이다.
준비물:
OS는 도커전용 OS인 가벼운 CoreOS를 선택하였다.
우선, 물리장치인 1PC의 호스트 전용 네트워크를 설정한다. 이 네트워크 기반으로 여러개의
VM을 뛰우기위함이다.
호스트 전용 네트워크 설정
Vagrantfile
VM을 생성하는 스크립트이며, 파일형태로 VM의 생성 정보를 유지하면 된다.
각각의 디렉토리에 Vagrantfile을 생성하여 3대의 VM을 목록을 작성한예이다.
vagrant 명령들
3대의 vm을 가진 docker 가 순식간에 각각의 프라이빗 네트워크를 가진채 생성이 되었다.