The software described in this documentation is either in Extended Support or Sustaining Support. See https://www.oracle.com/us/support/library/enterprise-linux-support-policies-069172.pdf for more information.
Oracle recommends that you upgrade the software described by this documentation as soon as possible.
The procedure in this section uses the LXC template script for
Oracle Linux (lxc-oracle), which is located
in /usr/share/lxc/templates.
An Oracle Linux container requires a minimum of 400 MB of disk space.
To create and start a container:
Create an Oracle Linux 6 container named
ol6ctr1using thelxc-oracletemplate script.[root@host ~]#
lxc-create -n ol6ctr1 -B btrfs -t oracle -- --release=6.latestlxc-create: No config file specified, using the default config /etc/lxc/default.conf Host is OracleServer 6.4 Create configuration file /container/ol6ctr1/config Downloading release 6.latest for x86_64 . . . yum-metadata-parser.x86_64 0:1.1.2-16.el6 zlib.x86_64 0:1.2.3-29.el6 Complete!NoteFor LXC version 1.0 and later, you must specify the -B btrfs option if you want to use the snapshot features of btrfs. For more information, see the
lxc-create(1)manual page.The lxc-create command runs the template script
lxc-oracleto create the container in/container/ol6ctr1with the btrfs subvolume/container/ol6ctr1/rootfsas its root file system. The command then uses yum to install the latest available update of Oracle Linux 6 from the Oracle Linux Yum Server. It also writes the container's configuration settings to the file/container/ol6ctr1/configand itsfstabfile to/container/ol6ctr1/fstab. The default log file for the container is/container/ol6ctr1/ol6ctr1.log.You can specify the following template options after the -- option to lxc-create:
- -a | --arch=i386|x86_64
Specifies the architecture. The default value is the architecture of the host.
-
--baseurl=
pkg_repo Specifies the file URI of a package repository. You must also use the --arch and --release options to specify the architecture and the release, for example:
#
mount -o loop OracleLinux-R7-GA-Everything-x86_64-dvd.iso /mnt#lxc-create -n ol70beta -B btrfs -t oracle -- -R 7.0 -a x86_64\--baseurl=file:///mnt/Server-
-P |
--patch=
path Patches the
rootfsat the specified path.- --privileged[=rt]
Allows you to adjust the values of certain kernel parameters under the
/prochierarchy.The container uses a privilege configuration file, which mounts
/procread-only with some exceptions. See Section 8.9, “Configuring Kernel Parameter Settings for Oracle Linux Containers”.This option also enables the
CAP_SYS_NICEcapability, which allows you to set negativenicevalues (that is, more favored for scheduling) for processes from within the container.If you specify the =rt (real-time) modifier, you can configure the
lxc.cgroup.cpu.rt_runtime_ussetting in the container's configuration file or when you start the container. This setting specifies the maximum continuous period in microseconds for which the container has access to CPU resources from the base period set by the system-wide value ofcpu.rt_period_us. Otherwise, a container uses the system-wide value ofcpu.rt_runtime_us, which might cause it to consume too many CPU resources. In addition, this modifier ensures that rebooting a container terminates all of its processes and boots it to a clean state.-
-R |
--release=
major.minor Specifies the major release number and minor update number of the Oracle release to install. The value of
majorcan be set to 4, 5, 6, or 7. If you specifylatestforminor, the latest available release packages for the major release are installed. If the host is running Oracle Linux, the default release is the same as the release installed on the host. Otherwise, the default release is the latest update of Oracle Linux 6.-
-r |
--rpms=
rpm_name Installs the specified RPM in the container.
-
-t |
--templatefs=
rootfs Specifies the path to the root file system of an existing system, container, or Oracle VM template that you want to copy. Do not specify this option with any other template option. See Section 8.4, “Creating Additional Containers”.
-
-u |
--url=
repo_URL Specifies a yum repository other than Oracle Public Yum. For example, you might want to perform the installation from a local yum server. The repository file in configured in
/etc/yum.repos.din the container's root file system. The default URL ishttps://yum.oracle.com.
If you want to create additional copies of the container in its initial state, create a snapshot of the container's root file system, for example:
#
btrfs subvolume snapshot /container/ol6ctr1/rootfs /container/ol6ctr1/rootfs_snapStart the container
ol6ctr1as a daemon that writes its diagnostic output to a log file other than the default log file.[root@host ~]#
lxc-start -n ol6ctr1 -d -o /container/ol6ctr1_debug.log -l DEBUGNoteIf you omit the -d option, the container's console opens in the current shell.
The following logging levels are available:
FATAL,CRIT,WARN,ERROR,NOTICE,INFO, andDEBUG. You can set a logging level for all lxc-* commands.If you run the ps -ef --forest command on the host system and the process tree below the
lxc-startprocess shows that the/usr/sbin/sshdand/sbin/mingettyprocesses have started in the container, you can log in to the container from the host. See Section 8.3, “Logging in to Containers”.

