1
0

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.

systemd-nspawnAdvent Calendar 2017

Day 7

systemd-nspawnをGCPで使ってみる

Posted at

systemd-nspawn Advent Calendar 2017 7日目の記事です。

GCPでsystemd-nspawnをやってみます

こんな構成にしてみたいと思います
ubuntuの中で走らせたApacheにリバースプロキシできればOK

gcp.png

# ブリッジインターフェイス作成
apt install bridge-utils
systemctl enable systemd-networkd
cd /etc/systemd/network/
curl -sL https://goo.gl/LygWai > br.network
curl -sL https://goo.gl/iHeGDK > bridge.netdev
curl -sL https://goo.gl/8KbBsW > eth0.network

# 転送設定
cd /etc/network/if-pre-up.d
curl -sL https://goo.gl/KX1qH3 > ore_iptables
chmod +x ore_iptables
curl -sL https://goo.gl/5N9v8K > /etc/sysctl.conf

# systemd-nspawn設定
apt install -y systemd-container debootstrap
curl -sL https://goo.gl/Y1KGge > /etc/systemd/system/systemd-nspawn@.service

# コンテナ配置
cd /var/lib/machines/
debootstrap --arch amd64 xenial ./ubuntu http://archive.ubuntu.com/ubuntu
curl -sL https://goo.gl/MogJPf > ubuntu/etc/systemd/network/80-container-host0.network

# コンテナ内部設定
systemd-nspawn -D ubuntu/ # コンテナ内へ
passwd # パスワード設定
systemd-nspawn -b -D ubuntu/ # bootしてログイン
systemctl enable systemd-networkd systemd-resolved.service
systemctl start systemd-networkd systemd-resolved.service
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
apt update && apt upgrade
apt install dbus
systemctl poweroff
machinectl start ubuntu

# nginx設定
apt install -y nginx
curl -sL https://goo.gl/mEHzTa > /etc/nginx/sites-available/default
systemctl restart nginx

できました(`・ω・´)v

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?