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