179
178

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vagrantでlxcを使う

Last updated at Posted at 2013-07-31

参考

インストール

sudo apt-get install -y vagrant-lxc
Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "debian/jessie64"
  config.vm.network :forwarded_port, host: 3000, guest: 80
end

config.vm.network :public_network, ip: "192.168.100.10", bridge: 'enp3s0'

LXCはpublic_network指定をサポートしていません。

  • LXCのtemplateは /usr/share/lxc/templates/にあります

起動

vagrant up --provider=lxc
vagrant ssh

停止

vagrant halt

box化

vagrant package
  • package.box が生成される。

X転送

vagrant ssh -- -X

sudo apt-get update
sudo apt-get install -y xhosts xterm

provision

Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "debian/jessie64"
  config.vm.provision :shell, :path => "provision.sh"
  config.vm.network :forwarded_port, host: 3000, guest: 80
end
provision.sh
## locales
echo "ja_JP.UTF-8 UTF-8" > /etc/locale.gen
locale-gen
update-locale LANG=ja_JP.UTF-8

## timezone
echo "Asia/Tokyo" > /etc/timezone 
dpkg-reconfigure -f noninteractive tzdata

#apt-get update
provision実施
vagrant provision
179
178
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
179
178

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?