...
The most compelling reason to use LXD is ability to transport between containers. Setup a second LXD host on the same network. In this example we end up with two hosts,
Host | Containers | Comment |
---|---|---|
myhost01 | Where we setup container01 with Apache running inside. | This will be the host we can to copy the container from also called remote host. |
myhost02 | Just empty at the moment. | This will be the client also called the local machine. |
Expose Remote Host
In order for the local machine to connect, the remote host needs to be setup to be exposed on the network with a password. Following the instructions here, that work has been done while initializing LXD.
Configure Local Machine
myhost02 (local machine) needs to be made aware of the remote host. I suppose there are multiple ways of doing this and interested in if there is automatic discovery. For now, I'm going to use direct IP address.
Code Block | ||
---|---|---|
| ||
lxc remote add myhost02 192.168.0.110
Certificate fingerprint: 119846805c57c71ce8308c6623977202f990eff85d334ddcfef6cacca4cfd883
ok (y/n)? y
Admin password for myhost02:
Client certificate stored at server: myhost02 |
Now the list has been updated to have myhost02 as an entry,
Code Block | ||
---|---|---|
| ||
lxc remote list
+-----------------+------------------------------------------+---------------+--------+--------+
| NAME | URL | PROTOCOL | PUBLIC | STATIC |
+-----------------+------------------------------------------+---------------+--------+--------+
| images | https://images.linuxcontainers.org | simplestreams | YES | NO |
+-----------------+------------------------------------------+---------------+--------+--------+
| local (default) | unix:// | lxd | NO | YES |
+-----------------+------------------------------------------+---------------+--------+--------+
| myhost02 | https://192.168.0.110:8443 | lxd | NO | NO |
+-----------------+------------------------------------------+---------------+--------+--------+
| ubuntu | https://cloud-images.ubuntu.com/releases | simplestreams | YES | YES |
+-----------------+------------------------------------------+---------------+--------+--------+
| ubuntu-daily | https://cloud-images.ubuntu.com/daily | simplestreams | YES | YES |
+-----------------+------------------------------------------+---------------+--------+--------+ |
Interacting with Remote Host
Interaction is exactly the same as a local container except you specify the host name,
Code Block | ||
---|---|---|
| ||
lxc list myhost02: # I know the colon is optional but it gets you thinking about the actual container on the host.
+------+-------+------+------+------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+-------+------+------+------+-----------+
# While local machine has some containers.
lxc list
+-------------+---------+----------------------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-------------+---------+----------------------+------+------------+-----------+
| container01 | RUNNING | 10.94.217.171 (eth0) | | PERSISTENT | 0 |
+-------------+---------+----------------------+------+------------+-----------+ |
Advanced Tuning of Containers
...