mirror of
https://github.com/TrentSPalmer/trentdocs_website.git
synced 2024-11-23 08:01:30 -08:00
extend arch_reddis_nspawn.md new nspawn.md
This commit is contained in:
parent
9966cd6fc7
commit
a533ac755b
@ -1,11 +1,3 @@
|
|||||||
# Quick Dirty Reddis Nspawn Container on Arch Linux
|
# Quick Dirty Reddis Nspawn Container on Arch Linux
|
||||||
|
|
||||||
## Create a FileSystem
|
Refer to the [Nspawn](nspawn.md) page for setting up the nspawn container.
|
||||||
|
|
||||||
```bash
|
|
||||||
cd /var/lib/machines
|
|
||||||
# create a directory
|
|
||||||
mkdir <container>
|
|
||||||
# use pacstrap to create a file system
|
|
||||||
pacstrap -i -c -d <container> base --ignore linux
|
|
||||||
```
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# Welcome to Trent Docs
|
# Welcome to Trent Docs
|
||||||
|
* [Nspawn Containers](nspawn.md)
|
||||||
* [Quick Dirty Reddis Nspawn Container on Arch Linux](arch_reddis_nspawn.md)
|
* [Quick Dirty Reddis Nspawn Container on Arch Linux](arch_reddis_nspawn.md)
|
||||||
|
|
||||||
<!---
|
<!---
|
||||||
|
107
docs/nspawn.md
Normal file
107
docs/nspawn.md
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
# Nspawn Containers
|
||||||
|
|
||||||
|
[Arch Linux Wiki for Nspawn Containers](https://wiki.archlinux.org/index.php/Systemd-nspawn)
|
||||||
|
|
||||||
|
### Create a FileSystem
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /var/lib/machines
|
||||||
|
# create a directory
|
||||||
|
mkdir <container>
|
||||||
|
# use pacstrap to create a file system
|
||||||
|
pacstrap -i -c -d <container> base --ignore linux
|
||||||
|
```
|
||||||
|
|
||||||
|
### First boot and create root password
|
||||||
|
|
||||||
|
```bash
|
||||||
|
systemd-nspawn -b -D <container>
|
||||||
|
passwd
|
||||||
|
poweroff
|
||||||
|
# if you want to nat the container add *-n* flag
|
||||||
|
systemd-nspawn -b -D <container> -n
|
||||||
|
# and to bind mount the package cache
|
||||||
|
systemd-nspawn -b -D <container> -n --bind=/var/cache/pacman/pkg
|
||||||
|
```
|
||||||
|
|
||||||
|
### Networking
|
||||||
|
|
||||||
|
On Arch, assuming you have systemd-networkd and systemd-resolved
|
||||||
|
set up correctly, networking from the host end of things should
|
||||||
|
just work.
|
||||||
|
However on Linode it does not. What does work on Linode is to create
|
||||||
|
a bridge interface. Two files for br0 will get the job done.
|
||||||
|
|
||||||
|
```text
|
||||||
|
# /etc/systemd/network/50-br0.netdev
|
||||||
|
[NetDev]
|
||||||
|
Name=br0
|
||||||
|
Kind=bridge
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```text
|
||||||
|
# /etc/systemd/network/50-br0.netdev
|
||||||
|
[Match]
|
||||||
|
Name=br0
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
Address=10.0.55.1/24
|
||||||
|
DHCPServer=yes
|
||||||
|
IPMasquerade=yes
|
||||||
|
```
|
||||||
|
|
||||||
|
Notice how the configuration file tells systemd-networkd to offer
|
||||||
|
DHCP service and to perform masquerade. You can modify the `systemd-nspawn`
|
||||||
|
command to use the bridge interface. Every container attached to this bridge
|
||||||
|
will be on the same subnet and able to talk to each other.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# first restart systemd-networkd to bring up the new bridge interface
|
||||||
|
systemctl restart systemd-networkd
|
||||||
|
# and add --network-bridge=br0 to systemd-nspawn command
|
||||||
|
systemd-nspawn -b -D <container> --network-bridge=br0 --bind=/var/cache/pacman/pkg
|
||||||
|
```
|
||||||
|
|
||||||
|
### Automatically Starting the Container
|
||||||
|
|
||||||
|
There are two ways to automate starting the container. You can override
|
||||||
|
`systemd-nspawn@.service` or create an *nspawn* file.
|
||||||
|
|
||||||
|
First enable machines.target
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# to override the systemd-nspawn@.service file
|
||||||
|
cp /lib/systemd/system/systemd-nspawn@.service /etc/systemd/system/systemd-nspawn@<container>.service
|
||||||
|
```
|
||||||
|
Edit `/etc/systemd/system/systemd-nspawn@<container>.service` to add the `systemd-nspawn` options
|
||||||
|
you want to the `ExecStart` command.
|
||||||
|
|
||||||
|
Or create `/etc/systemd/nspawn/<container>.nspawn`
|
||||||
|
```text
|
||||||
|
# /etc/systemd/nspawn/<container>.nspawn
|
||||||
|
Bind=/var/cache/pacman/pkg
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
Bridge=br0
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# in either case
|
||||||
|
systemctl start/enable systemd-nspawn@<container>
|
||||||
|
# to get a shell
|
||||||
|
machinectl shell <container>
|
||||||
|
# and then to get an environment
|
||||||
|
bash
|
||||||
|
```
|
||||||
|
|
||||||
|
### Initial Configuration Inside The Container
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# set time zone if you don't want UTC
|
||||||
|
timedatectl set-timezone <timezone>
|
||||||
|
# enable ntp, networktime
|
||||||
|
timedatectl set-ntp 1
|
||||||
|
```
|
||||||
|
|
||||||
|
[If you want to change the locale](https://wiki.archlinux.org/index.php/locale)
|
@ -4,5 +4,6 @@ theme: readthedocs
|
|||||||
|
|
||||||
pages:
|
pages:
|
||||||
- 'Home': index.md
|
- 'Home': index.md
|
||||||
|
- 'Nspawn': nspawn.md
|
||||||
- 'Quick Dirty Reddis Nspawn Container on Arch Linux': arch_reddis_nspawn.md
|
- 'Quick Dirty Reddis Nspawn Container on Arch Linux': arch_reddis_nspawn.md
|
||||||
|
|
||||||
|
@ -52,6 +52,11 @@
|
|||||||
<a class="" href="..">Home</a>
|
<a class="" href="..">Home</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li class="toctree-l1">
|
||||||
|
|
||||||
|
<a class="" href="../nspawn/">Nspawn</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li class="toctree-l1 current">
|
<li class="toctree-l1 current">
|
||||||
|
|
||||||
<a class="current" href="./">Quick Dirty Reddis Nspawn Container on Arch Linux</a>
|
<a class="current" href="./">Quick Dirty Reddis Nspawn Container on Arch Linux</a>
|
||||||
@ -59,12 +64,6 @@
|
|||||||
|
|
||||||
<li class="toctree-l2"><a href="#quick-dirty-reddis-nspawn-container-on-arch-linux">Quick Dirty Reddis Nspawn Container on Arch Linux</a></li>
|
<li class="toctree-l2"><a href="#quick-dirty-reddis-nspawn-container-on-arch-linux">Quick Dirty Reddis Nspawn Container on Arch Linux</a></li>
|
||||||
|
|
||||||
<ul>
|
|
||||||
|
|
||||||
<li><a class="toctree-l3" href="#create-a-filesystem">Create a FileSystem</a></li>
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@ -102,13 +101,7 @@
|
|||||||
<div class="section">
|
<div class="section">
|
||||||
|
|
||||||
<h1 id="quick-dirty-reddis-nspawn-container-on-arch-linux">Quick Dirty Reddis Nspawn Container on Arch Linux</h1>
|
<h1 id="quick-dirty-reddis-nspawn-container-on-arch-linux">Quick Dirty Reddis Nspawn Container on Arch Linux</h1>
|
||||||
<h2 id="create-a-filesystem">Create a FileSystem</h2>
|
<p>Refer to the <a href="../nspawn/">Nspawn</a> page for setting up the nspawn container.</p>
|
||||||
<pre><code class="bash">cd /var/lib/machines
|
|
||||||
# create a directory
|
|
||||||
mkdir <container>
|
|
||||||
# use pacstrap to create a file system
|
|
||||||
pacstrap -i -c -d <container> base --ignore linux
|
|
||||||
</code></pre>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -117,7 +110,7 @@ pacstrap -i -c -d <container> base --ignore linux
|
|||||||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||||
|
|
||||||
|
|
||||||
<a href=".." class="btn btn-neutral" title="Home"><span class="icon icon-circle-arrow-left"></span> Previous</a>
|
<a href="../nspawn/" class="btn btn-neutral" title="Nspawn"><span class="icon icon-circle-arrow-left"></span> Previous</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -143,7 +136,7 @@ pacstrap -i -c -d <container> base --ignore linux
|
|||||||
<span class="rst-current-version" data-toggle="rst-current-version">
|
<span class="rst-current-version" data-toggle="rst-current-version">
|
||||||
|
|
||||||
|
|
||||||
<span><a href=".." style="color: #fcfcfc;">« Previous</a></span>
|
<span><a href="../nspawn/" style="color: #fcfcfc;">« Previous</a></span>
|
||||||
|
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
|
@ -60,6 +60,11 @@
|
|||||||
|
|
||||||
<li class="toctree-l1">
|
<li class="toctree-l1">
|
||||||
|
|
||||||
|
<a class="" href="nspawn/">Nspawn</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="toctree-l1">
|
||||||
|
|
||||||
<a class="" href="arch_reddis_nspawn/">Quick Dirty Reddis Nspawn Container on Arch Linux</a>
|
<a class="" href="arch_reddis_nspawn/">Quick Dirty Reddis Nspawn Container on Arch Linux</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
@ -97,6 +102,7 @@
|
|||||||
|
|
||||||
<h1 id="welcome-to-trent-docs">Welcome to Trent Docs</h1>
|
<h1 id="welcome-to-trent-docs">Welcome to Trent Docs</h1>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><a href="nspawn/">Nspawn Containers</a></li>
|
||||||
<li><a href="arch_reddis_nspawn/">Quick Dirty Reddis Nspawn Container on Arch Linux</a></li>
|
<li><a href="arch_reddis_nspawn/">Quick Dirty Reddis Nspawn Container on Arch Linux</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<!---
|
<!---
|
||||||
@ -109,7 +115,7 @@
|
|||||||
|
|
||||||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||||
|
|
||||||
<a href="arch_reddis_nspawn/" class="btn btn-neutral float-right" title="Quick Dirty Reddis Nspawn Container on Arch Linux">Next <span class="icon icon-circle-arrow-right"></span></a>
|
<a href="nspawn/" class="btn btn-neutral float-right" title="Nspawn">Next <span class="icon icon-circle-arrow-right"></span></a>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -137,7 +143,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<span style="margin-left: 15px"><a href="arch_reddis_nspawn/" style="color: #fcfcfc">Next »</a></span>
|
<span style="margin-left: 15px"><a href="nspawn/" style="color: #fcfcfc">Next »</a></span>
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -148,5 +154,5 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
MkDocs version : 0.16.3
|
MkDocs version : 0.16.3
|
||||||
Build Date UTC : 2017-06-27 22:19:20
|
Build Date UTC : 2017-06-27 23:43:49
|
||||||
-->
|
-->
|
||||||
|
@ -2,28 +2,58 @@
|
|||||||
"docs": [
|
"docs": [
|
||||||
{
|
{
|
||||||
"location": "/",
|
"location": "/",
|
||||||
"text": "Welcome to Trent Docs\n\n\n\n\nQuick Dirty Reddis Nspawn Container on Arch Linux",
|
"text": "Welcome to Trent Docs\n\n\n\n\nNspawn Containers\n\n\nQuick Dirty Reddis Nspawn Container on Arch Linux",
|
||||||
"title": "Home"
|
"title": "Home"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"location": "/#welcome-to-trent-docs",
|
"location": "/#welcome-to-trent-docs",
|
||||||
"text": "Quick Dirty Reddis Nspawn Container on Arch Linux",
|
"text": "Nspawn Containers Quick Dirty Reddis Nspawn Container on Arch Linux",
|
||||||
"title": "Welcome to Trent Docs"
|
"title": "Welcome to Trent Docs"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"location": "/nspawn/",
|
||||||
|
"text": "Nspawn Containers\n\n\nArch Linux Wiki for Nspawn Containers\n\n\nCreate a FileSystem\n\n\ncd /var/lib/machines\n# create a directory\nmkdir <container>\n# use pacstrap to create a file system\npacstrap -i -c -d <container> base --ignore linux\n\n\n\n\nFirst boot and create root password\n\n\nsystemd-nspawn -b -D <container>\npasswd\npoweroff\n# if you want to nat the container add *-n* flag\nsystemd-nspawn -b -D <container> -n\n# and to bind mount the package cache\nsystemd-nspawn -b -D <container> -n --bind=/var/cache/pacman/pkg\n\n\n\n\nNetworking\n\n\nOn Arch, assuming you have systemd-networkd and systemd-resolved\nset up correctly, networking from the host end of things should\njust work.\n\nHowever on Linode it does not. What does work on Linode is to create\na bridge interface. Two files for br0 will get the job done.\n\n\n# /etc/systemd/network/50-br0.netdev\n[NetDev]\nName=br0\nKind=bridge\n\n\n\n\n# /etc/systemd/network/50-br0.netdev\n[Match]\nName=br0\n\n[Network]\nAddress=10.0.55.1/24\nDHCPServer=yes\nIPMasquerade=yes\n\n\n\n\nNotice how the configuration file tells systemd-networkd to offer\nDHCP service and to perform masquerade. You can modify the \nsystemd-nspawn\n\ncommand to use the bridge interface. Every container attached to this bridge\nwill be on the same subnet and able to talk to each other.\n\n\n# first restart systemd-networkd to bring up the new bridge interface\nsystemctl restart systemd-networkd\n# and add --network-bridge=br0 to systemd-nspawn command\nsystemd-nspawn -b -D <container> --network-bridge=br0 --bind=/var/cache/pacman/pkg\n\n\n\n\nAutomatically Starting the Container\n\n\nThere are two ways to automate starting the container. You can override\n\nsystemd-nspawn@.service\n or create an \nnspawn\n file. \n\n\nFirst enable machines.target\n\n\n# to override the systemd-nspawn@.service file\ncp /lib/systemd/system/systemd-nspawn@.service /etc/systemd/system/systemd-nspawn@<container>.service\n\n\n\n\nEdit \n/etc/systemd/system/systemd-nspawn@<container>.service\n to add the \nsystemd-nspawn\n options\nyou want to the \nExecStart\n command.\n\n\nOr create \n/etc/systemd/nspawn/<container>.nspawn\n\n\n# /etc/systemd/nspawn/<container>.nspawn\nBind=/var/cache/pacman/pkg\n\n[Network]\nBridge=br0\n\n\n\n\n# in either case\nsystemctl start/enable systemd-nspawn@<container>\n# to get a shell\nmachinectl shell <container>\n# and then to get an environment\nbash\n\n\n\n\nInitial Configuration Inside The Container\n\n\n# set time zone if you don't want UTC\ntimedatectl set-timezone <timezone>\n# enable ntp, networktime\ntimedatectl set-ntp 1\n\n\n\n\nIf you want to change the locale",
|
||||||
|
"title": "Nspawn"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/nspawn/#nspawn-containers",
|
||||||
|
"text": "Arch Linux Wiki for Nspawn Containers",
|
||||||
|
"title": "Nspawn Containers"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/nspawn/#create-a-filesystem",
|
||||||
|
"text": "cd /var/lib/machines\n# create a directory\nmkdir <container>\n# use pacstrap to create a file system\npacstrap -i -c -d <container> base --ignore linux",
|
||||||
|
"title": "Create a FileSystem"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/nspawn/#first-boot-and-create-root-password",
|
||||||
|
"text": "systemd-nspawn -b -D <container>\npasswd\npoweroff\n# if you want to nat the container add *-n* flag\nsystemd-nspawn -b -D <container> -n\n# and to bind mount the package cache\nsystemd-nspawn -b -D <container> -n --bind=/var/cache/pacman/pkg",
|
||||||
|
"title": "First boot and create root password"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/nspawn/#networking",
|
||||||
|
"text": "On Arch, assuming you have systemd-networkd and systemd-resolved\nset up correctly, networking from the host end of things should\njust work. \nHowever on Linode it does not. What does work on Linode is to create\na bridge interface. Two files for br0 will get the job done. # /etc/systemd/network/50-br0.netdev\n[NetDev]\nName=br0\nKind=bridge # /etc/systemd/network/50-br0.netdev\n[Match]\nName=br0\n\n[Network]\nAddress=10.0.55.1/24\nDHCPServer=yes\nIPMasquerade=yes Notice how the configuration file tells systemd-networkd to offer\nDHCP service and to perform masquerade. You can modify the systemd-nspawn \ncommand to use the bridge interface. Every container attached to this bridge\nwill be on the same subnet and able to talk to each other. # first restart systemd-networkd to bring up the new bridge interface\nsystemctl restart systemd-networkd\n# and add --network-bridge=br0 to systemd-nspawn command\nsystemd-nspawn -b -D <container> --network-bridge=br0 --bind=/var/cache/pacman/pkg",
|
||||||
|
"title": "Networking"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/nspawn/#automatically-starting-the-container",
|
||||||
|
"text": "There are two ways to automate starting the container. You can override systemd-nspawn@.service or create an nspawn file. First enable machines.target # to override the systemd-nspawn@.service file\ncp /lib/systemd/system/systemd-nspawn@.service /etc/systemd/system/systemd-nspawn@<container>.service Edit /etc/systemd/system/systemd-nspawn@<container>.service to add the systemd-nspawn options\nyou want to the ExecStart command. Or create /etc/systemd/nspawn/<container>.nspawn # /etc/systemd/nspawn/<container>.nspawn\nBind=/var/cache/pacman/pkg\n\n[Network]\nBridge=br0 # in either case\nsystemctl start/enable systemd-nspawn@<container>\n# to get a shell\nmachinectl shell <container>\n# and then to get an environment\nbash",
|
||||||
|
"title": "Automatically Starting the Container"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "/nspawn/#initial-configuration-inside-the-container",
|
||||||
|
"text": "# set time zone if you don't want UTC\ntimedatectl set-timezone <timezone>\n# enable ntp, networktime\ntimedatectl set-ntp 1 If you want to change the locale",
|
||||||
|
"title": "Initial Configuration Inside The Container"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"location": "/arch_reddis_nspawn/",
|
"location": "/arch_reddis_nspawn/",
|
||||||
"text": "Quick Dirty Reddis Nspawn Container on Arch Linux\n\n\nCreate a FileSystem\n\n\ncd /var/lib/machines\n# create a directory\nmkdir <container>\n# use pacstrap to create a file system\npacstrap -i -c -d <container> base --ignore linux",
|
"text": "Quick Dirty Reddis Nspawn Container on Arch Linux\n\n\nRefer to the \nNspawn\n page for setting up the nspawn container.",
|
||||||
"title": "Quick Dirty Reddis Nspawn Container on Arch Linux"
|
"title": "Quick Dirty Reddis Nspawn Container on Arch Linux"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"location": "/arch_reddis_nspawn/#quick-dirty-reddis-nspawn-container-on-arch-linux",
|
"location": "/arch_reddis_nspawn/#quick-dirty-reddis-nspawn-container-on-arch-linux",
|
||||||
"text": "",
|
"text": "Refer to the Nspawn page for setting up the nspawn container.",
|
||||||
"title": "Quick Dirty Reddis Nspawn Container on Arch Linux"
|
"title": "Quick Dirty Reddis Nspawn Container on Arch Linux"
|
||||||
},
|
|
||||||
{
|
|
||||||
"location": "/arch_reddis_nspawn/#create-a-filesystem",
|
|
||||||
"text": "cd /var/lib/machines\n# create a directory\nmkdir <container>\n# use pacstrap to create a file system\npacstrap -i -c -d <container> base --ignore linux",
|
|
||||||
"title": "Create a FileSystem"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
249
site/nspawn/index.html
Normal file
249
site/nspawn/index.html
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||||
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||||
|
<title>Nspawn - Trent Docs</title>
|
||||||
|
<link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="../css/theme.css" type="text/css" />
|
||||||
|
<link rel="stylesheet" href="../css/theme_extra.css" type="text/css" />
|
||||||
|
<link rel="stylesheet" href="../css/highlight.css">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Current page data
|
||||||
|
var mkdocs_page_name = "Nspawn";
|
||||||
|
var mkdocs_page_input_path = "nspawn.md";
|
||||||
|
var mkdocs_page_url = "/nspawn/";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script src="../js/jquery-2.1.1.min.js"></script>
|
||||||
|
<script src="../js/modernizr-2.8.3.min.js"></script>
|
||||||
|
<script type="text/javascript" src="../js/highlight.pack.js"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="wy-body-for-nav" role="document">
|
||||||
|
|
||||||
|
<div class="wy-grid-for-nav">
|
||||||
|
|
||||||
|
|
||||||
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
|
||||||
|
<div class="wy-side-nav-search">
|
||||||
|
<a href=".." class="icon icon-home"> Trent Docs</a>
|
||||||
|
<div role="search">
|
||||||
|
<form id ="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
||||||
|
<input type="text" name="q" placeholder="Search docs" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||||
|
<ul class="current">
|
||||||
|
|
||||||
|
|
||||||
|
<li class="toctree-l1">
|
||||||
|
|
||||||
|
<a class="" href="..">Home</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="toctree-l1 current">
|
||||||
|
|
||||||
|
<a class="current" href="./">Nspawn</a>
|
||||||
|
<ul class="subnav">
|
||||||
|
|
||||||
|
<li class="toctree-l2"><a href="#nspawn-containers">Nspawn Containers</a></li>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
|
||||||
|
<li><a class="toctree-l3" href="#create-a-filesystem">Create a FileSystem</a></li>
|
||||||
|
|
||||||
|
<li><a class="toctree-l3" href="#first-boot-and-create-root-password">First boot and create root password</a></li>
|
||||||
|
|
||||||
|
<li><a class="toctree-l3" href="#networking">Networking</a></li>
|
||||||
|
|
||||||
|
<li><a class="toctree-l3" href="#automatically-starting-the-container">Automatically Starting the Container</a></li>
|
||||||
|
|
||||||
|
<li><a class="toctree-l3" href="#initial-configuration-inside-the-container">Initial Configuration Inside The Container</a></li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="toctree-l1">
|
||||||
|
|
||||||
|
<a class="" href="../arch_reddis_nspawn/">Quick Dirty Reddis Nspawn Container on Arch Linux</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||||
|
|
||||||
|
|
||||||
|
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||||
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||||
|
<a href="..">Trent Docs</a>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="wy-nav-content">
|
||||||
|
<div class="rst-content">
|
||||||
|
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||||
|
<ul class="wy-breadcrumbs">
|
||||||
|
<li><a href="..">Docs</a> »</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li>Nspawn</li>
|
||||||
|
<li class="wy-breadcrumbs-aside">
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<hr/>
|
||||||
|
</div>
|
||||||
|
<div role="main">
|
||||||
|
<div class="section">
|
||||||
|
|
||||||
|
<h1 id="nspawn-containers">Nspawn Containers</h1>
|
||||||
|
<p><a href="https://wiki.archlinux.org/index.php/Systemd-nspawn">Arch Linux Wiki for Nspawn Containers</a></p>
|
||||||
|
<h3 id="create-a-filesystem">Create a FileSystem</h3>
|
||||||
|
<pre><code class="bash">cd /var/lib/machines
|
||||||
|
# create a directory
|
||||||
|
mkdir <container>
|
||||||
|
# use pacstrap to create a file system
|
||||||
|
pacstrap -i -c -d <container> base --ignore linux
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="first-boot-and-create-root-password">First boot and create root password</h3>
|
||||||
|
<pre><code class="bash">systemd-nspawn -b -D <container>
|
||||||
|
passwd
|
||||||
|
poweroff
|
||||||
|
# if you want to nat the container add *-n* flag
|
||||||
|
systemd-nspawn -b -D <container> -n
|
||||||
|
# and to bind mount the package cache
|
||||||
|
systemd-nspawn -b -D <container> -n --bind=/var/cache/pacman/pkg
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="networking">Networking</h3>
|
||||||
|
<p>On Arch, assuming you have systemd-networkd and systemd-resolved
|
||||||
|
set up correctly, networking from the host end of things should
|
||||||
|
just work.<br />
|
||||||
|
However on Linode it does not. What does work on Linode is to create
|
||||||
|
a bridge interface. Two files for br0 will get the job done.</p>
|
||||||
|
<pre><code class="text"># /etc/systemd/network/50-br0.netdev
|
||||||
|
[NetDev]
|
||||||
|
Name=br0
|
||||||
|
Kind=bridge
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<pre><code class="text"># /etc/systemd/network/50-br0.netdev
|
||||||
|
[Match]
|
||||||
|
Name=br0
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
Address=10.0.55.1/24
|
||||||
|
DHCPServer=yes
|
||||||
|
IPMasquerade=yes
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>Notice how the configuration file tells systemd-networkd to offer
|
||||||
|
DHCP service and to perform masquerade. You can modify the <code>systemd-nspawn</code>
|
||||||
|
command to use the bridge interface. Every container attached to this bridge
|
||||||
|
will be on the same subnet and able to talk to each other.</p>
|
||||||
|
<pre><code class="bash"># first restart systemd-networkd to bring up the new bridge interface
|
||||||
|
systemctl restart systemd-networkd
|
||||||
|
# and add --network-bridge=br0 to systemd-nspawn command
|
||||||
|
systemd-nspawn -b -D <container> --network-bridge=br0 --bind=/var/cache/pacman/pkg
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="automatically-starting-the-container">Automatically Starting the Container</h3>
|
||||||
|
<p>There are two ways to automate starting the container. You can override
|
||||||
|
<code>systemd-nspawn@.service</code> or create an <em>nspawn</em> file. </p>
|
||||||
|
<p>First enable machines.target</p>
|
||||||
|
<pre><code class="bash"># to override the systemd-nspawn@.service file
|
||||||
|
cp /lib/systemd/system/systemd-nspawn@.service /etc/systemd/system/systemd-nspawn@<container>.service
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>Edit <code>/etc/systemd/system/systemd-nspawn@<container>.service</code> to add the <code>systemd-nspawn</code> options
|
||||||
|
you want to the <code>ExecStart</code> command.</p>
|
||||||
|
<p>Or create <code>/etc/systemd/nspawn/<container>.nspawn</code></p>
|
||||||
|
<pre><code class="text"># /etc/systemd/nspawn/<container>.nspawn
|
||||||
|
Bind=/var/cache/pacman/pkg
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
Bridge=br0
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<pre><code class="bash"># in either case
|
||||||
|
systemctl start/enable systemd-nspawn@<container>
|
||||||
|
# to get a shell
|
||||||
|
machinectl shell <container>
|
||||||
|
# and then to get an environment
|
||||||
|
bash
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h3 id="initial-configuration-inside-the-container">Initial Configuration Inside The Container</h3>
|
||||||
|
<pre><code class="bash"># set time zone if you don't want UTC
|
||||||
|
timedatectl set-timezone <timezone>
|
||||||
|
# enable ntp, networktime
|
||||||
|
timedatectl set-ntp 1
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p><a href="https://wiki.archlinux.org/index.php/locale">If you want to change the locale</a></p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<footer>
|
||||||
|
|
||||||
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||||
|
|
||||||
|
<a href="../arch_reddis_nspawn/" class="btn btn-neutral float-right" title="Quick Dirty Reddis Nspawn Container on Arch Linux">Next <span class="icon icon-circle-arrow-right"></span></a>
|
||||||
|
|
||||||
|
|
||||||
|
<a href=".." class="btn btn-neutral" title="Home"><span class="icon icon-circle-arrow-left"></span> Previous</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<div role="contentinfo">
|
||||||
|
<!-- Copyright etc -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Built with <a href="http://www.mkdocs.org">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="rst-versions" role="note" style="cursor: pointer">
|
||||||
|
<span class="rst-current-version" data-toggle="rst-current-version">
|
||||||
|
|
||||||
|
|
||||||
|
<span><a href=".." style="color: #fcfcfc;">« Previous</a></span>
|
||||||
|
|
||||||
|
|
||||||
|
<span style="margin-left: 15px"><a href="../arch_reddis_nspawn/" style="color: #fcfcfc">Next »</a></span>
|
||||||
|
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<script src="../js/theme.js"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -50,6 +50,11 @@
|
|||||||
|
|
||||||
<li class="toctree-l1">
|
<li class="toctree-l1">
|
||||||
|
|
||||||
|
<a class="" href="nspawn/">Nspawn</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="toctree-l1">
|
||||||
|
|
||||||
<a class="" href="arch_reddis_nspawn/">Quick Dirty Reddis Nspawn Container on Arch Linux</a>
|
<a class="" href="arch_reddis_nspawn/">Quick Dirty Reddis Nspawn Container on Arch Linux</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
@ -10,6 +10,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>/nspawn/</loc>
|
||||||
|
<lastmod>2017-06-27</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<url>
|
<url>
|
||||||
<loc>/arch_reddis_nspawn/</loc>
|
<loc>/arch_reddis_nspawn/</loc>
|
||||||
<lastmod>2017-06-27</lastmod>
|
<lastmod>2017-06-27</lastmod>
|
||||||
|
Loading…
Reference in New Issue
Block a user