85 $ sudo lxc-create -t debian -n deb-testing -- -r testing |
85 $ sudo lxc-create -t debian -n deb-testing -- -r testing |
86 $ sudo lxc-create -t debian -n deb-stable -- -r stable -a amd64 |
86 $ sudo lxc-create -t debian -n deb-stable -- -r stable -a amd64 |
87 |
87 |
88 $ sudo lxc-create -t alpine -n alpine-3.7 -- -r 3.7 |
88 $ sudo lxc-create -t alpine -n alpine-3.7 -- -r 3.7 |
89 |
89 |
|
90 Examples of destroying container:: |
|
91 |
|
92 $ sudo lxc-destroy --name $NAME |
|
93 |
90 Each template has own options, which can be passed after ``--``. To get help on template specific |
94 Each template has own options, which can be passed after ``--``. To get help on template specific |
91 options run:: |
95 options run:: |
92 |
96 |
93 $ /usr/share/lxc/templates/lxc-ubuntu -h |
97 $ /usr/share/lxc/templates/lxc-ubuntu -h |
94 $ /usr/share/lxc/templates/lxc-debian -h |
98 $ /usr/share/lxc/templates/lxc-debian -h |
107 |
111 |
108 Creating container by downloading pre-built image:: |
112 Creating container by downloading pre-built image:: |
109 |
113 |
110 sudo lxc-create -t download -n alpine-edge -- -d alpine -r edge -a amd64 |
114 sudo lxc-create -t download -n alpine-edge -- -d alpine -r edge -a amd64 |
111 sudo lxc-create -t download -n debian-sid -- -d debian -r sid -a amd64 |
115 sudo lxc-create -t download -n debian-sid -- -d debian -r sid -a amd64 |
|
116 sudo lxc-create -t download -n ubuntu-bio -- --dist ubuntu --release bionic --arch amd64 |
112 |
117 |
113 Since LXC v3.0 sh-templates moved to separate project and only 4 are left supported:: |
118 Since LXC v3.0 sh-templates moved to separate project and only 4 are left supported:: |
114 |
119 |
115 $ lxc-create my-busybox -t busybox |
120 $ lxc-create my-busybox -t busybox |
116 $ lxc-create my-x -t download |
121 $ lxc-create my-x -t download |
132 $ echo nameserver 8.8.8.8 | sudo tee /var/lib/lxc/$NAME/rootfs/etc/resolv.conf |
137 $ echo nameserver 8.8.8.8 | sudo tee /var/lib/lxc/$NAME/rootfs/etc/resolv.conf |
133 |
138 |
134 LXC Container management |
139 LXC Container management |
135 ======================== |
140 ======================== |
136 |
141 |
137 List available VMs:: |
142 List available containers:: |
138 |
143 |
139 $ sudo lxc-ls |
144 $ sudo lxc-ls |
140 |
145 $ sudo lxc-ls --fancy |
141 Start VM:: |
146 |
|
147 Show details about container:: |
|
148 |
|
149 $ sudo lxc-info --name $NAME |
|
150 |
|
151 Start container:: |
142 |
152 |
143 $ sudo lxc-start -n $NAME |
153 $ sudo lxc-start -n $NAME |
144 |
154 |
145 Safely stop VM (honoring init system):: |
155 Show boot process output during container start with ``-F``:: |
146 |
156 |
147 $ sudo lxc-halt -n $NAME |
157 $ sudo lxc-start -n $NAME -F |
148 |
158 $ sudo lxc-start -n $NAME --foreground |
149 Urgently stop VM:: |
159 |
|
160 Safely stop container (by default sends ``SIGPWR`` signal to container ``init`` process and waits 60 |
|
161 sec and then send ``SIGKILL``):: |
150 |
162 |
151 $ sudo lxc-stop -n $NAME |
163 $ sudo lxc-stop -n $NAME |
|
164 |
|
165 To signal reboot (by default sends ``SIGINT`` signal to container ``init`` process):: |
|
166 |
|
167 $ sudo lxc-stop -n $NAME -r |
|
168 $ sudo lxc-stop -n $NAME --reboot |
|
169 |
|
170 Urgently stop container (kills all processes):: |
|
171 |
|
172 $ sudo lxc-stop -n $NAME -k |
|
173 $ sudo lxc-stop -n $NAME --kill |
152 |
174 |
153 Mark container to start on boot in ``/var/lib/lxc/$NAME/config``:: |
175 Mark container to start on boot in ``/var/lib/lxc/$NAME/config``:: |
154 |
176 |
155 lxc.start.auto = 1 |
177 lxc.start.auto = 1 |
156 |
178 |