Linux Container is Google's open-source lightweight virtualization solution, and is a resource Container, LXC for short. LXC can create its own file system, namely rootfs.
I. Create a file system and a mount table
1. Prepare the Directory
Mkdir/lxc
Then go to the/lxc directory and create the root file system directory.
Mkdir rootfs
Go to the/lxc/rootfs directory and create other directories.
1 mkdir bin dev etc lib lib64 proc sbin sys usr var
2. Create a mount table
In the/lxc directory, create a new file fstab and edit the file as follows:
/Bin/lxc/rootfs/bin none ro, bind 0 0
/Sbin/lxc/rootfs/sbin none ro, bind 0 0
/Lib/lxc/rootfs/lib none ro, bind 0 0
/Lib64/lxc/rootfs/lib64 none ro, bind 0 0
/Etc/lxc/rootfs/etc none ro, bind 0 0
/Usr/lxc/rootfs/usr none ro, bind 0 0
/Dev/lxc/rootfs/dev none rw, bind 0 0
/Dev/pts/lxc/rootfs/dev/pts none rw, bind 0 0
/Proc/lxc/rootfs/proc defaults 0 0
/Sys/lxc/rootfs/sys sysfs defaults 0 0
The general idea is to mount the/bin/sbin/lib/etc directory of the host operating system to the corresponding directory under/lxc/rootfs.
Ii. Start lxc
1. Edit the lxc configuration file
Edit the config file as follows:
Lxc. utsname = host_name
Lxc. rootfs =/lxc/rootfs
Lxc. mount =/lxc/fstab
2. Start lxc and execute bash commands.
Lxc-execute-n lxc1-f config bash
In this way, a lxiner named lxc1 is started. Executing bash is equivalent to entering the Container. If the output on the terminal is abnormal, use the reset command.
3. view the lxc internal File System
Bash-4.1 # ls
Bin data dev etc lib lib64 proc sbin sys usr var
We found that operations can only be performed within/lxc/rootfs.
Linux container technology-LXC-related technical knowledge
Linux container technology-Analysis of the execution process of creating a virtual machine in LXC
Use shell scripts to monitor applications in the LXC application container
Cgroup and LXC (Linux container) Installation Details (CentOS 6.2) System
Linux container Virtual Technology LXC Concise Manual