Auto Start LXD Container
Posted on
Bagaimana caranya supaya container LXD bisa auto start ketika mesin dinyalakan? sehingga kita tidak perlu menjalankan perintah lxc start nama-container
. Fitur boot.autostart
adalah jawabannya. Berikut ini contohnya:
Saya punya container:
» sudo lxc list
+-----------+---------+-----------------------+----------------------------------------------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-----------+---------+-----------------------+----------------------------------------------+------------+-----------+
| archlinux | STOPPED | | | PERSISTENT | 0 |
+-----------+---------+-----------------------+----------------------------------------------+------------+-----------+
| farm | STOPPED | | | PERSISTENT | 0 |
+-----------+---------+-----------------------+----------------------------------------------+------------+-----------+
| haproxy | RUNNING | 10.205.252.41 (eth0) | fd42:720:6748:f67b:216:3eff:fe22:1c8f (eth0) | PERSISTENT | 0 |
+-----------+---------+-----------------------+----------------------------------------------+------------+-----------+
| web2 | RUNNING | 10.205.252.216 (eth0) | fd42:720:6748:f67b:216:3eff:feee:6f0a (eth0) | PERSISTENT | 0 |
+-----------+---------+-----------------------+----------------------------------------------+------------+-----------+
Saya ingin membuat haproxy autostart ketika mesin dinyalakan:
sudo lxc config set haproxy boot.autostart true
Selesai, kita bisa reboot komputer dan lihat hasilnya. Selain cara tadi, kita juga bisa langsung edit config haproxy kemudian menambahkan boot.autostart: "true"
. Mudah ya, semoga bermanfaat.