]> git.proxmox.com Git - pve-docs.git/blame - pct.adoc
gui-create-ct-general.png: update screenshot
[pve-docs.git] / pct.adoc
CommitLineData
80c0adcb 1[[chapter_pct]]
0c6b782f 2ifdef::manvolnum[]
b2f242ab 3pct(1)
7e2fdb3d 4======
5f09af76
DM
5:pve-toplevel:
6
0c6b782f
DM
7NAME
8----
9
10pct - Tool to manage Linux Containers (LXC) on Proxmox VE
11
12
49a5e11c 13SYNOPSIS
0c6b782f
DM
14--------
15
16include::pct.1-synopsis.adoc[]
17
18DESCRIPTION
19-----------
20endif::manvolnum[]
21
22ifndef::manvolnum[]
23Proxmox Container Toolkit
24=========================
194d2f29 25:pve-toplevel:
0c6b782f 26endif::manvolnum[]
5f09af76 27ifdef::wiki[]
cb84ed18 28:title: Linux Container
5f09af76 29endif::wiki[]
4a2ae9ed
DM
30
31Containers are a lightweight alternative to fully virtualized
32VMs. Instead of emulating a complete Operating System (OS), containers
33simply use the OS of the host they run on. This implies that all
34containers use the same kernel, and that they can access resources
35from the host directly.
36
37This is great because containers do not waste CPU power nor memory due
38to kernel emulation. Container run-time costs are close to zero and
39usually negligible. But there are also some drawbacks you need to
40consider:
41
42* You can only run Linux based OS inside containers, i.e. it is not
a8e99754 43 possible to run FreeBSD or MS Windows inside.
4a2ae9ed 44
a8e99754 45* For security reasons, access to host resources needs to be
4a2ae9ed 46 restricted. This is done with AppArmor, SecComp filters and other
a8e99754 47 kernel features. Be prepared that some syscalls are not allowed
4a2ae9ed
DM
48 inside containers.
49
50{pve} uses https://linuxcontainers.org/[LXC] as underlying container
51technology. We consider LXC as low-level library, which provides
a8e99754 52countless options. It would be too difficult to use those tools
4a2ae9ed
DM
53directly. Instead, we provide a small wrapper called `pct`, the
54"Proxmox Container Toolkit".
55
a8e99754 56The toolkit is tightly coupled with {pve}. That means that it is aware
4a2ae9ed
DM
57of the cluster setup, and it can use the same network and storage
58resources as fully virtualized VMs. You can even use the {pve}
59firewall, or manage containers using the HA framework.
60
61Our primary goal is to offer an environment as one would get from a
62VM, but without the additional overhead. We call this "System
63Containers".
64
99d2e25b 65NOTE: If you want to run micro-containers (with docker, rkt, ...), it
70a42028 66is best to run them inside a VM.
4a2ae9ed
DM
67
68
99f6ae1a
DM
69Technology Overview
70-------------------
71
72* LXC (https://linuxcontainers.org/)
73
74* Integrated into {pve} graphical user interface (GUI)
75
76* Easy to use command line tool `pct`
77
78* Access via {pve} REST API
79
80* lxcfs to provide containerized /proc file system
81
82* AppArmor/Seccomp to improve security
83
84* CRIU: for live migration (planned)
85
86* Use latest available kernels (4.4.X)
87
88* Image based deployment (templates)
89
90* Use {pve} storage library
91
92* Container setup from host (network, DNS, storage, ...)
93
94
4a2ae9ed
DM
95Security Considerations
96-----------------------
97
98Containers use the same kernel as the host, so there is a big attack
99surface for malicious users. You should consider this fact if you
100provide containers to totally untrusted people. In general, fully
a8e99754 101virtualized VMs provide better isolation.
4a2ae9ed
DM
102
103The good news is that LXC uses many kernel security features like
104AppArmor, CGroups and PID and user namespaces, which makes containers
304eb5a9 105usage quite secure.
3bd9d0cf 106
53e3cd6f
DM
107Guest Operating System Configuration
108------------------------------------
109
110We normally try to detect the operating system type inside the
111container, and then modify some files inside the container to make
112them work as expected. Here is a short list of things we do at
113container startup:
114
115set /etc/hostname:: to set the container name
116
117modify /etc/hosts:: to allow lookup of the local hostname
118
119network setup:: pass the complete network setup to the container
120
121configure DNS:: pass information about DNS servers
122
123adapt the init system:: for example, fix the number of spawned getty processes
124
125set the root password:: when creating a new container
126
127rewrite ssh_host_keys:: so that each container has unique keys
128
129randomize crontab:: so that cron does not start at the same time on all containers
130
131Changes made by {PVE} are enclosed by comment markers:
132
133----
134# --- BEGIN PVE ---
135<data>
136# --- END PVE ---
137----
138
139Those markers will be inserted at a reasonable location in the
140file. If such a section already exists, it will be updated in place
141and will not be moved.
142
143Modification of a file can be prevented by adding a `.pve-ignore.`
144file for it. For instance, if the file `/etc/.pve-ignore.hosts`
145exists then the `/etc/hosts` file will not be touched. This can be a
146simple empty file creatd via:
147
148 # touch /etc/.pve-ignore.hosts
149
150Most modifications are OS dependent, so they differ between different
151distributions and versions. You can completely disable modifications
152by manually setting the `ostype` to `unmanaged`.
153
154OS type detection is done by testing for certain files inside the
155container:
156
157Ubuntu:: inspect /etc/lsb-release (`DISTRIB_ID=Ubuntu`)
158
159Debian:: test /etc/debian_version
160
161Fedora:: test /etc/fedora-release
162
163RedHat or CentOS:: test /etc/redhat-release
164
165ArchLinux:: test /etc/arch-release
166
167Alpine:: test /etc/alpine-release
168
169Gentoo:: test /etc/gentoo-release
170
171NOTE: Container start fails if the configured `ostype` differs from the auto
172detected type.
173
174
80c0adcb 175[[pct_container_images]]
d61bab51
DM
176Container Images
177----------------
178
8c1189b6
FG
179Container images, sometimes also referred to as ``templates'' or
180``appliances'', are `tar` archives which contain everything to run a
d61bab51 181container. You can think of it as a tidy container backup. Like most
8c1189b6 182modern container toolkits, `pct` uses those images when you create a
d61bab51
DM
183new container, for example:
184
185 pct create 999 local:vztmpl/debian-8.0-standard_8.0-1_amd64.tar.gz
186
26ca7ff5 187{pve} itself ships a set of basic templates for most common
8c1189b6 188operating systems, and you can download them using the `pveam` (short
d61bab51
DM
189for {pve} Appliance Manager) command line utility. You can also
190download https://www.turnkeylinux.org/[TurnKey Linux] containers using
191that tool (or the graphical user interface).
192
3a6fa247
DM
193Our image repositories contain a list of available images, and there
194is a cron job run each day to download that list. You can trigger that
195update manually with:
196
197 pveam update
198
199After that you can view the list of available images using:
200
201 pveam available
202
8c1189b6
FG
203You can restrict this large list by specifying the `section` you are
204interested in, for example basic `system` images:
3a6fa247
DM
205
206.List available system images
207----
208# pveam available --section system
209system archlinux-base_2015-24-29-1_x86_64.tar.gz
210system centos-7-default_20160205_amd64.tar.xz
211system debian-6.0-standard_6.0-7_amd64.tar.gz
212system debian-7.0-standard_7.0-3_amd64.tar.gz
213system debian-8.0-standard_8.0-1_amd64.tar.gz
214system ubuntu-12.04-standard_12.04-1_amd64.tar.gz
215system ubuntu-14.04-standard_14.04-1_amd64.tar.gz
216system ubuntu-15.04-standard_15.04-1_amd64.tar.gz
217system ubuntu-15.10-standard_15.10-1_amd64.tar.gz
218----
219
a8e99754 220Before you can use such a template, you need to download them into one
8c1189b6 221of your storages. You can simply use storage `local` for that
3a6fa247
DM
222purpose. For clustered installations, it is preferred to use a shared
223storage so that all nodes can access those images.
224
225 pveam download local debian-8.0-standard_8.0-1_amd64.tar.gz
226
24f73a63 227You are now ready to create containers using that image, and you can
8c1189b6 228list all downloaded images on storage `local` with:
24f73a63
DM
229
230----
231# pveam list local
232local:vztmpl/debian-8.0-standard_8.0-1_amd64.tar.gz 190.20MB
233----
234
a8e99754 235The above command shows you the full {pve} volume identifiers. They include
24f73a63 236the storage name, and most other {pve} commands can use them. For
5eba0743 237example you can delete that image later with:
24f73a63
DM
238
239 pveam remove local:vztmpl/debian-8.0-standard_8.0-1_amd64.tar.gz
3a6fa247 240
d61bab51 241
80c0adcb 242[[pct_container_storage]]
70a42028
DM
243Container Storage
244-----------------
245
246Traditional containers use a very simple storage model, only allowing
247a single mount point, the root file system. This was further
8c1189b6
FG
248restricted to specific file system types like `ext4` and `nfs`.
249Additional mounts are often done by user provided scripts. This turned
a8e99754 250out to be complex and error prone, so we try to avoid that now.
70a42028
DM
251
252Our new LXC based container model is more flexible regarding
253storage. First, you can have more than a single mount point. This
254allows you to choose a suitable storage for each application. For
255example, you can use a relatively slow (and thus cheap) storage for
256the container root file system. Then you can use a second mount point
257to mount a very fast, distributed storage for your database
4f785ca7
DM
258application. See section <<pct_mount_points,Mount Points>> for further
259details.
70a42028
DM
260
261The second big improvement is that you can use any storage type
262supported by the {pve} storage library. That means that you can store
8c1189b6
FG
263your containers on local `lvmthin` or `zfs`, shared `iSCSI` storage,
264or even on distributed storage systems like `ceph`. It also enables us
265to use advanced storage features like snapshots and clones. `vzdump`
a8e99754 266can also use the snapshot feature to provide consistent container
70a42028
DM
267backups.
268
269Last but not least, you can also mount local devices directly, or
270mount local directories using bind mounts. That way you can access
271local storage inside containers with zero overhead. Such bind mounts
a8e99754 272also provide an easy way to share data between different containers.
70a42028 273
eeecce95 274
4f785ca7
DM
275FUSE Mounts
276~~~~~~~~~~~
277
278WARNING: Because of existing issues in the Linux kernel's freezer
279subsystem the usage of FUSE mounts inside a container is strongly
280advised against, as containers need to be frozen for suspend or
281snapshot mode backups.
282
283If FUSE mounts cannot be replaced by other mounting mechanisms or storage
284technologies, it is possible to establish the FUSE mount on the Proxmox host
285and use a bind mount point to make it accessible inside the container.
286
287
288Using Quotas Inside Containers
289~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
290
291Quotas allow to set limits inside a container for the amount of disk
292space that each user can use. This only works on ext4 image based
293storage types and currently does not work with unprivileged
294containers.
295
296Activating the `quota` option causes the following mount options to be
297used for a mount point:
298`usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0`
299
300This allows quotas to be used like you would on any other system. You
301can initialize the `/aquota.user` and `/aquota.group` files by running
302
303----
304quotacheck -cmug /
305quotaon /
306----
307
308and edit the quotas via the `edquota` command. Refer to the documentation
309of the distribution running inside the container for details.
310
311NOTE: You need to run the above commands for every mount point by passing
312the mount point's path instead of just `/`.
313
314
315Using ACLs Inside Containers
316~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317
318The standard Posix **A**ccess **C**ontrol **L**ists are also available inside containers.
319ACLs allow you to set more detailed file ownership than the traditional user/
320group/others model.
321
322
f3afbb70 323[[pct_settings]]
4f785ca7
DM
324Container Settings
325------------------
326
304eb5a9
EK
327[[pct_general]]
328General Settings
329~~~~~~~~~~~~~~~~
330
331General settings of a container include
332
333* the *Node* : the physical server on which the container will run
334* the *CT ID*: a unique number in this {pve} installation used to identify your container
335* *Hostname*: the hostname of the container
336* *Resource Pool*: a logical group of containers and VMs
337* *Password*: the root password of the container
338* *SSH Public Key*: a public key for connecting to the root account over SSH
339* *Unprivileged container*: this option allows to choose at creation time
340if you want to create a privileged or unprivileged container.
341
342
343Privileged Containers
344^^^^^^^^^^^^^^^^^^^^^
345
346Security is done by dropping capabilities, using mandatory access
347control (AppArmor), SecComp filters and namespaces. The LXC team
348considers this kind of container as unsafe, and they will not consider
349new container escape exploits to be security issues worthy of a CVE
350and quick fix. So you should use this kind of containers only inside a
351trusted environment, or when no untrusted task is running as root in
352the container.
353
354
355Unprivileged Containers
356^^^^^^^^^^^^^^^^^^^^^^^
357
358This kind of containers use a new kernel feature called user
359namespaces. The root UID 0 inside the container is mapped to an
360unprivileged user outside the container. This means that most security
361issues (container escape, resource abuse, ...) in those containers
362will affect a random unprivileged user, and so would be a generic
363kernel security bug rather than an LXC issue. The LXC team thinks
364unprivileged containers are safe by design.
365
366NOTE: If the container uses systemd as an init system, please be
367aware the systemd version running inside the container should be equal
368or greater than 220.
369
9a5e9443 370[[pct_cpu]]
9a5e9443
DM
371CPU
372~~~
373
097aa949
DM
374[thumbnail="gui-create-ct-cpu.png"]
375
9a5e9443
DM
376You can restrict the number of visible CPUs inside the container using
377the `cores` option. This is implemented using the Linux 'cpuset'
378cgroup (**c**ontrol *group*). A special task inside `pvestatd` tries
379to distribute running containers among available CPUs. You can view
380the assigned CPUs using the following command:
381
382----
383# pct cpusets
384 ---------------------
385 102: 6 7
386 105: 2 3 4 5
387 108: 0 1
388 ---------------------
389----
390
391Containers use the host kernel directly, so all task inside a
392container are handled by the host CPU scheduler. {pve} uses the Linux
393'CFS' (**C**ompletely **F**air **S**cheduler) scheduler by default,
394which has additional bandwidth control options.
395
396[horizontal]
0725e3c6
DM
397
398`cpulimit`: :: You can use this option to further limit assigned CPU
9a5e9443
DM
399time. Please note that this is a floating point number, so it is
400perfectly valid to assign two cores to a container, but restrict
401overall CPU consumption to half a core.
402+
403----
404cores: 2
405cpulimit: 0.5
406----
407
0725e3c6 408`cpuunits`: :: This is a relative weight passed to the kernel
9a5e9443
DM
409scheduler. The larger the number is, the more CPU time this container
410gets. Number is relative to the weights of all the other running
411containers. The default is 1024. You can use this setting to
412prioritize some containers.
413
414
415[[pct_memory]]
416Memory
417~~~~~~
418
097aa949
DM
419[thumbnail="gui-create-ct-memory.png"]
420
9a5e9443
DM
421Container memory is controlled using the cgroup memory controller.
422
423[horizontal]
424
0725e3c6 425`memory`: :: Limit overall memory usage. This corresponds
9a5e9443
DM
426to the `memory.limit_in_bytes` cgroup setting.
427
0725e3c6 428`swap`: :: Allows the container to use additional swap memory from the
9a5e9443
DM
429host swap space. This corresponds to the `memory.memsw.limit_in_bytes`
430cgroup setting, which is set to the sum of both value (`memory +
431swap`).
432
4f785ca7
DM
433
434[[pct_mount_points]]
9e44e493
DM
435Mount Points
436~~~~~~~~~~~~
eeecce95 437
097aa949
DM
438[thumbnail="gui-create-ct-root-disk.png"]
439
01639994
FG
440The root mount point is configured with the `rootfs` property, and you can
441configure up to 10 additional mount points. The corresponding options
442are called `mp0` to `mp9`, and they can contain the following setting:
443
444include::pct-mountpoint-opts.adoc[]
445
9e44e493
DM
446Currently there are basically three types of mount points: storage backed
447mount points, bind mounts and device mounts.
448
5eba0743 449.Typical container `rootfs` configuration
4c3b5c77
DM
450----
451rootfs: thin1:base-100-disk-1,size=8G
452----
453
454
5eba0743 455Storage Backed Mount Points
4c3b5c77 456^^^^^^^^^^^^^^^^^^^^^^^^^^^
01639994 457
9e44e493 458Storage backed mount points are managed by the {pve} storage subsystem and come
eeecce95
WB
459in three different flavors:
460
5eba0743 461- Image based: these are raw images containing a single ext4 formatted file
eeecce95 462 system.
5eba0743 463- ZFS subvolumes: these are technically bind mounts, but with managed storage,
eeecce95
WB
464 and thus allow resizing and snapshotting.
465- Directories: passing `size=0` triggers a special case where instead of a raw
466 image a directory is created.
467
4c3b5c77 468
5eba0743 469Bind Mount Points
4c3b5c77 470^^^^^^^^^^^^^^^^^
01639994 471
9baca183
FG
472Bind mounts allow you to access arbitrary directories from your Proxmox VE host
473inside a container. Some potential use cases are:
474
475- Accessing your home directory in the guest
476- Accessing an USB device directory in the guest
acccc49b 477- Accessing an NFS mount from the host in the guest
9baca183 478
eeecce95 479Bind mounts are considered to not be managed by the storage subsystem, so you
9baca183 480cannot make snapshots or deal with quotas from inside the container. With
eeecce95 481unprivileged containers you might run into permission problems caused by the
9baca183
FG
482user mapping and cannot use ACLs.
483
8c1189b6 484NOTE: The contents of bind mount points are not backed up when using `vzdump`.
eeecce95 485
6b707f2c
FG
486WARNING: For security reasons, bind mounts should only be established
487using source directories especially reserved for this purpose, e.g., a
488directory hierarchy under `/mnt/bindmounts`. Never bind mount system
489directories like `/`, `/var` or `/etc` into a container - this poses a
9baca183
FG
490great security risk.
491
492NOTE: The bind mount source path must not contain any symlinks.
493
494For example, to make the directory `/mnt/bindmounts/shared` accessible in the
495container with ID `100` under the path `/shared`, use a configuration line like
8c1189b6
FG
496`mp0: /mnt/bindmounts/shared,mp=/shared` in `/etc/pve/lxc/100.conf`.
497Alternatively, use `pct set 100 -mp0 /mnt/bindmounts/shared,mp=/shared` to
9baca183 498achieve the same result.
6b707f2c 499
4c3b5c77 500
5eba0743 501Device Mount Points
4c3b5c77 502^^^^^^^^^^^^^^^^^^^
fe154a4f 503
7432d78e
FG
504Device mount points allow to mount block devices of the host directly into the
505container. Similar to bind mounts, device mounts are not managed by {PVE}'s
506storage subsystem, but the `quota` and `acl` options will be honored.
507
508NOTE: Device mount points should only be used under special circumstances. In
509most cases a storage backed mount point offers the same performance and a lot
510more features.
511
8c1189b6 512NOTE: The contents of device mount points are not backed up when using `vzdump`.
01639994 513
4c3b5c77 514
80c0adcb 515[[pct_container_network]]
f5c351f0
DM
516Network
517~~~~~~~
04c569f6 518
097aa949
DM
519[thumbnail="gui-create-ct-network.png"]
520
bac8c385 521You can configure up to 10 network interfaces for a single
8c1189b6 522container. The corresponding options are called `net0` to `net9`, and
bac8c385
DM
523they can contain the following setting:
524
525include::pct-network-opts.adoc[]
04c569f6
DM
526
527
139a9019
DM
528[[pct_startup_and_shutdown]]
529Automatic Start and Shutdown of Containers
530~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
531
532After creating your containers, you probably want them to start automatically
533when the host system boots. For this you need to select the option 'Start at
534boot' from the 'Options' Tab of your container in the web interface, or set it with
535the following command:
536
537 pct set <ctid> -onboot 1
538
4dbeb548
DM
539.Start and Shutdown Order
540// use the screenshot from qemu - its the same
541[thumbnail="gui-qemu-edit-start-order.png"]
542
139a9019
DM
543If you want to fine tune the boot order of your containers, you can use the following
544parameters :
545
546* *Start/Shutdown order*: Defines the start order priority. E.g. set it to 1 if
547you want the CT to be the first to be started. (We use the reverse startup
548order for shutdown, so a container with a start order of 1 would be the last to
549be shut down)
550* *Startup delay*: Defines the interval between this container start and subsequent
551containers starts . E.g. set it to 240 if you want to wait 240 seconds before starting
552other containers.
553* *Shutdown timeout*: Defines the duration in seconds {pve} should wait
554for the container to be offline after issuing a shutdown command.
555By default this value is set to 60, which means that {pve} will issue a
556shutdown request, wait 60s for the machine to be offline, and if after 60s
557the machine is still online will notify that the shutdown action failed.
558
559Please note that containers without a Start/Shutdown order parameter will always
560start after those where the parameter is set, and this parameter only
561makes sense between the machines running locally on a host, and not
562cluster-wide.
563
564
51e33128
FG
565Backup and Restore
566------------------
567
5eba0743 568
2175e37b
FG
569Container Backup
570~~~~~~~~~~~~~~~~
571
8c1189b6
FG
572It is possible to use the `vzdump` tool for container backup. Please
573refer to the `vzdump` manual page for details.
574
51e33128 575
2175e37b
FG
576Restoring Container Backups
577~~~~~~~~~~~~~~~~~~~~~~~~~~~
578
8c1189b6
FG
579Restoring container backups made with `vzdump` is possible using the
580`pct restore` command. By default, `pct restore` will attempt to restore as much
2175e37b
FG
581of the backed up container configuration as possible. It is possible to override
582the backed up configuration by manually setting container options on the command
8c1189b6 583line (see the `pct` manual page for details).
2175e37b 584
8c1189b6 585NOTE: `pvesm extractconfig` can be used to view the backed up configuration
2175e37b
FG
586contained in a vzdump archive.
587
588There are two basic restore modes, only differing by their handling of mount
589points:
590
4c3b5c77 591
8c1189b6
FG
592``Simple'' Restore Mode
593^^^^^^^^^^^^^^^^^^^^^^^
2175e37b
FG
594
595If neither the `rootfs` parameter nor any of the optional `mpX` parameters
596are explicitly set, the mount point configuration from the backed up
597configuration file is restored using the following steps:
598
599. Extract mount points and their options from backup
600. Create volumes for storage backed mount points (on storage provided with the
601`storage` parameter, or default local storage if unset)
602. Extract files from backup archive
603. Add bind and device mount points to restored configuration (limited to root user)
604
605NOTE: Since bind and device mount points are never backed up, no files are
606restored in the last step, but only the configuration options. The assumption
607is that such mount points are either backed up with another mechanism (e.g.,
608NFS space that is bind mounted into many containers), or not intended to be
609backed up at all.
610
611This simple mode is also used by the container restore operations in the web
612interface.
613
4c3b5c77 614
8c1189b6
FG
615``Advanced'' Restore Mode
616^^^^^^^^^^^^^^^^^^^^^^^^^
2175e37b
FG
617
618By setting the `rootfs` parameter (and optionally, any combination of `mpX`
8c1189b6 619parameters), the `pct restore` command is automatically switched into an
2175e37b
FG
620advanced mode. This advanced mode completely ignores the `rootfs` and `mpX`
621configuration options contained in the backup archive, and instead only
622uses the options explicitly provided as parameters.
623
624This mode allows flexible configuration of mount point settings at restore time,
625for example:
626
627* Set target storages, volume sizes and other options for each mount point
628individually
629* Redistribute backed up files according to new mount point scheme
630* Restore to device and/or bind mount points (limited to root user)
631
51e33128 632
8c1189b6 633Managing Containers with `pct`
04c569f6
DM
634------------------------------
635
8c1189b6 636`pct` is the tool to manage Linux Containers on {pve}. You can create
04c569f6
DM
637and destroy containers, and control execution (start, stop, migrate,
638...). You can use pct to set parameters in the associated config file,
639like network configuration or memory limits.
640
5eba0743 641
04c569f6
DM
642CLI Usage Examples
643~~~~~~~~~~~~~~~~~~
644
645Create a container based on a Debian template (provided you have
5eba0743 646already downloaded the template via the web interface)
04c569f6
DM
647
648 pct create 100 /var/lib/vz/template/cache/debian-8.0-standard_8.0-1_amd64.tar.gz
649
650Start container 100
651
652 pct start 100
653
654Start a login session via getty
655
656 pct console 100
657
658Enter the LXC namespace and run a shell as root user
659
660 pct enter 100
661
662Display the configuration
663
664 pct config 100
665
8c1189b6 666Add a network interface called `eth0`, bridged to the host bridge `vmbr0`,
04c569f6
DM
667set the address and gateway, while it's running
668
669 pct set 100 -net0 name=eth0,bridge=vmbr0,ip=192.168.15.147/24,gw=192.168.15.1
670
671Reduce the memory of the container to 512MB
672
0585f29a
DM
673 pct set 100 -memory 512
674
04c569f6 675
fe57a420
FG
676Obtaining Debugging Logs
677~~~~~~~~~~~~~~~~~~~~~~~~
678
679In case `pct start` is unable to start a specific container, it might be
680helpful to collect debugging output by running `lxc-start` (replace `ID` with
681the container's ID):
682
683 lxc-start -n ID -F -l DEBUG -o /tmp/lxc-ID.log
684
685This command will attempt to start the container in foreground mode, to stop the container run `pct shutdown ID` or `pct stop ID` in a second terminal.
686
687The collected debug log is written to `/tmp/lxc-ID.log`.
688
689NOTE: If you have changed the container's configuration since the last start
690attempt with `pct start`, you need to run `pct start` at least once to also
691update the configuration used by `lxc-start`.
692
c7bc47af
DM
693
694[[pct_configuration]]
695Configuration
696-------------
697
698The `/etc/pve/lxc/<CTID>.conf` file stores container configuration,
699where `<CTID>` is the numeric ID of the given container. Like all
700other files stored inside `/etc/pve/`, they get automatically
701replicated to all other cluster nodes.
702
703NOTE: CTIDs < 100 are reserved for internal purposes, and CTIDs need to be
704unique cluster wide.
705
706.Example Container Configuration
707----
708ostype: debian
709arch: amd64
710hostname: www
711memory: 512
712swap: 512
713net0: bridge=vmbr0,hwaddr=66:64:66:64:64:36,ip=dhcp,name=eth0,type=veth
714rootfs: local:107/vm-107-disk-1.raw,size=7G
715----
716
717Those configuration files are simple text files, and you can edit them
718using a normal text editor (`vi`, `nano`, ...). This is sometimes
719useful to do small corrections, but keep in mind that you need to
720restart the container to apply such changes.
721
722For that reason, it is usually better to use the `pct` command to
723generate and modify those files, or do the whole thing using the GUI.
724Our toolkit is smart enough to instantaneously apply most changes to
725running containers. This feature is called "hot plug", and there is no
726need to restart the container in that case.
727
728
729File Format
730~~~~~~~~~~~
731
732Container configuration files use a simple colon separated key/value
733format. Each line has the following format:
734
735-----
736# this is a comment
737OPTION: value
738-----
739
740Blank lines in those files are ignored, and lines starting with a `#`
741character are treated as comments and are also ignored.
742
743It is possible to add low-level, LXC style configuration directly, for
744example:
745
746 lxc.init_cmd: /sbin/my_own_init
747
748or
749
750 lxc.init_cmd = /sbin/my_own_init
751
752Those settings are directly passed to the LXC low-level tools.
753
754
755[[pct_snapshots]]
756Snapshots
757~~~~~~~~~
758
759When you create a snapshot, `pct` stores the configuration at snapshot
760time into a separate snapshot section within the same configuration
761file. For example, after creating a snapshot called ``testsnapshot'',
762your configuration file will look like this:
763
764.Container configuration with snapshot
765----
766memory: 512
767swap: 512
768parent: testsnaphot
769...
770
771[testsnaphot]
772memory: 512
773swap: 512
774snaptime: 1457170803
775...
776----
777
778There are a few snapshot related properties like `parent` and
779`snaptime`. The `parent` property is used to store the parent/child
780relationship between snapshots. `snaptime` is the snapshot creation
781time stamp (Unix epoch).
782
783
784[[pct_options]]
785Options
786~~~~~~~
787
788include::pct.conf.5-opts.adoc[]
789
790
2a11aa70
DM
791Locks
792-----
793
794Container migrations, snapshots and backups (`vzdump`) set a lock to
795prevent incompatible concurrent actions on the affected container. Sometimes
796you need to remove such a lock manually (e.g., after a power failure).
797
798 pct unlock <CTID>
799
800CAUTION: Only do that if you are sure the action which set the lock is
801no longer running.
802
fe57a420 803
0c6b782f 804ifdef::manvolnum[]
3bd9d0cf
DM
805
806Files
807------
808
809`/etc/pve/lxc/<CTID>.conf`::
810
811Configuration file for the container '<CTID>'.
812
813
0c6b782f
DM
814include::pve-copyright.adoc[]
815endif::manvolnum[]
816
817
818
819
820
821
822