Help us understand the problem. What is going on with this article?

Vagrantでlxcを使う

More than 3 years have passed since last update.

参考

インストール

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
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away