SlideShare a Scribd company logo
Isolating an applications using LXC – Linux Containers
Linux Containers have got huge attention lately due to high demand and business shifting towards
cloud computing and virtualization. Linux Containers are the process level based virtualization
which uses the same operating system kernel. The main advantage of LXC is the lightweight when
compared to the traditional Hardware based virtualization (KVM) and Xen.
The Idea of containers was implemented by Solaris Zones as well as BSD jails quite a few years ago.
However, they required custom kernels, which was often a major setback. LXC uses these kernel
features:
 Kernel namespaces (ipc, uts, mount, pid, network, and user)
 AppArmor and SELinux profiles
 Seccomp policies
 Chroots (using pivot_root)
 Kernel capabilities
 Control groups (cgroups).
Namespaces:
Namespaces provide the first, and most straightforward, form of isolation: processes
running within a container cannot see, and even less affect, processes running in another container,
or in the host system.
Control Groups:
cgroups are the key components in the Linux Containers. They take care of resource
allocation of memory, CPU, disk I/O. LXC shares the equal amount of memory or CPU resources
across multiple containers. This plays a major role where Nesting of Linux Containers are
implemented.
Installing containers:
Containers can be installed as other applications. The table below specifies the way of
installing, configuring and running application in containers.
~>Installing Container
apt-get install lxc
Create an "Ubuntu" based container named cn-01. This will download set of files form internet for
the first time. There are some predefined container templateto create as Alpine Linux, Alt Linux,
Arch Linux, busybox, CentOS, Cirros, Debian, Fedora, OpenMandriva, OpenSUSE, Oracle, Plamo,
sshd, Ubuntu Cloud and Ubuntu.
lxc-create -t ubuntu -n cn-01
~>check the contaibers config as:
lxc-checkconfig
Isolating an applications using LXC – Linux Containers
~> Start the container (in the background)
lxc-start -n cn-01 -d
~>Check the container status as below to get the status and IP address of the container:
lxc-ls --fancy
~>Enter the container in one of those ways## Attach to the container's console (ctrl-a + q to
detach)
lxc-console -n p1
~>SSH into it
ssh ubuntu@<ip from lxc-info>
~>Stop the container in one of those ways
poweroff
~>Stop it cleanly from the outside
lxc-stop -n cn-01
~>Kill it from the outside
lxc-stop -n cn-01 -k
Installing application inside Container -1:
As an example we shall install apache2 web server inside the container which can be
accessed in the host machine.
sudo apt-get install apache2
Checking LXC configs
Isolating an applications using LXC – Linux Containers
Getting into LXC console:
sdf sdf ffsdfsdf
SSH login into container:
Installing Apache in the container:
Isolating an applications using LXC – Linux Containers
Once the Apache has been configured and up and running it can be viewable via host browser as
below
Isolating an applications using LXC – Linux Containers
The container info can be retrieved using the below command as such.
Container Configuration:
Services such as Network, resource allocation (memory, CPU etc) can be configured in
“/var/lib/lxc/<container-name>config”
Hooks:
Hooks are the useful and convenient way to run custom scripts inside the containers. There
are different types of hooks which can be invoked.
 lxc.hook.pre-start (calledbefore any initialization is done)
 lxc.hook.pre-mount (calledafter creating the mount namespace but before mounting
anything)
 lxc.hook.mount (called after the mounts but before pivot_root)
 lxc.hook.autodev (identical to mount but only called if using autodev)
Isolating an applications using LXC – Linux Containers
 lxc.hook.start (called in the container right before /sbin/init)
 lxc.hook.post-stop (run after the container has been shutdown)
 lxc.hook.clone (calledwhen cloning a container into a new one)
Additionally each network section may also define two additional hooks:
 lxc.network.script.up (calledin the network namespace after the interface was created)
 lxc.network.script.down (called in the network namespace before destroying the interface)
Example for creating a pre-start hook script.
lxc.hook.pre-start = /var/lib/lxc/<container-name>/pre-start.sh
The container can be deleted or destroyed once the container purpose has solved.
lxc-shutdown -n cn-01
Once the container gets shutdown and it is ready to be destroyed once the necessary data has
been backed up,
lxc-destory -n cn-01.
Installing application inside Container -2:
As an example, we can install Kali Linux and Metasploit inside a container and we can use
kali Linux via web browser using OpenBox and NoVNC.
I have tried this example via kali Linux. Please find the steps involved in this to install and
configure Docker under kali Linux.
apt-get update
apt-get -y install docker.io
ln -sf /usr/bin/docker.io /usr/local/bin/docker
Finally, and optionally, let’s configure Docker to start when the server boots:
update-rc.d docker.io defaults
service docker start
Once the docker service is up and running, we can use pull docker meta images (smaller footprint)
as below.
docker pull kalilinux/kali-linux-docker
Once the initial set up of the kali Linux within Docker gets completed, we can start installing
Isolating an applications using LXC – Linux Containers
Metasploit inside the docker.
docker run -t -i -p 6080:6080 kalilinux/kali-linux-docker /bin/bash
You will be welcomed within kali linux inside the docker with a command prompt. You can further
start installing Metasploit package as below.
apt-get install metasploit
Building Your Own Kali Linux Docker Image
If you want to build your own Kali images rather than use our pre-made ones, we’ve made it easy
with the following script hosted on Kali Linux Docker on Github. These images are best built on a
Linux system or any other OS that can debootstrap.
#!/bin/bash
# Install dependencies (debbootstrap)
sudo apt-get install debootstrap
# Fetch the latest Kali debootstrap script from git
curl
"http://git.kali.org/gitweb/?p=packages/debootstrap.git;a=blob_plain;f=scripts/kali;hb=HEA
D" &gt; kali-debootstrap &amp;&amp;
sudo debootstrap kali ./kali-root http://http.kali.org/kali ./kali-debootstrap &amp;&amp;
# Import the Kali image into Docker
sudo tar -C kali-root -c . | sudo docker import - kalilinux/kali &amp;&amp;
sudo rm -rf ./kali-root &amp;&amp;
# Test the Kali Docker Image
docker run -t -i kalilinux/kali cat /etc/debian_version &amp;&amp;
echo "Build OK" || echo "Build failed!"
Configuring Openbox and noVNC:
Openbox and noVNC can be downloaded from below paths and configure accordingly.
noVNC: https://github.com/kanaka/noVNC
Openbox: http://openbox.org/wiki/Main_Page
Conclusion:
We have covered the basics of the Container concepts from installing, configuring and
running an application inside the container. Dockers are built on top of LXC. In Dockers case, its
advantage is that its open-source engine can be used to pack, ship, and run any application as a
lightweight, portable, self-sufficient LXC container that runs virtually anywhere. It’s a packaging
system for applications.
Ad

More Related Content

What's hot (20)

Docker 102 - Immutable Infrastructure
Docker 102 - Immutable InfrastructureDocker 102 - Immutable Infrastructure
Docker 102 - Immutable Infrastructure
Adrian Otto
 
Red Hat Enterprise Linux OpenStack Platform 7 - VM Instance HA Architecture
Red Hat Enterprise Linux OpenStack Platform 7 - VM Instance HA ArchitectureRed Hat Enterprise Linux OpenStack Platform 7 - VM Instance HA Architecture
Red Hat Enterprise Linux OpenStack Platform 7 - VM Instance HA Architecture
Etsuji Nakai
 
LXC, Docker, security: is it safe to run applications in Linux Containers?
LXC, Docker, security: is it safe to run applications in Linux Containers?LXC, Docker, security: is it safe to run applications in Linux Containers?
LXC, Docker, security: is it safe to run applications in Linux Containers?
Jérôme Petazzoni
 
Docker: Please contain your excitement
Docker: Please contain your excitementDocker: Please contain your excitement
Docker: Please contain your excitement
johnnnl
 
Containers - What are they and Atomic
Containers - What are they and AtomicContainers - What are they and Atomic
Containers - What are they and Atomic
Syed Shaaf
 
LXC
LXCLXC
LXC
Wu Fan-Cheng
 
Docker 101 2015-05-28
Docker 101 2015-05-28Docker 101 2015-05-28
Docker 101 2015-05-28
Adrian Otto
 
Linux Containers (LXC)
Linux Containers (LXC)Linux Containers (LXC)
Linux Containers (LXC)
Vladimir Melnic
 
LXC NSAttach
LXC NSAttachLXC NSAttach
LXC NSAttach
Darshan Parmar
 
Containers are the future of the Cloud
Containers are the future of the CloudContainers are the future of the Cloud
Containers are the future of the Cloud
Pavel Odintsov
 
Lxc – next gen virtualization for cloud intro (cloudexpo)
Lxc – next gen virtualization for cloud   intro (cloudexpo)Lxc – next gen virtualization for cloud   intro (cloudexpo)
Lxc – next gen virtualization for cloud intro (cloudexpo)
Boden Russell
 
Docker 1.11 @ Docker SF Meetup
Docker 1.11 @ Docker SF MeetupDocker 1.11 @ Docker SF Meetup
Docker 1.11 @ Docker SF Meetup
Docker, Inc.
 
Linuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best PracticesLinuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best Practices
christophm
 
What's really the difference between a VM and a Container?
What's really the difference between a VM and a Container?What's really the difference between a VM and a Container?
What's really the difference between a VM and a Container?
Adrian Otto
 
Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby
Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby
Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby
Michelle Antebi
 
Octo talk : docker multi-host networking
Octo talk : docker multi-host networking Octo talk : docker multi-host networking
Octo talk : docker multi-host networking
Hervé Leclerc
 
Linux Container Technology 101
Linux Container Technology 101Linux Container Technology 101
Linux Container Technology 101
inside-BigData.com
 
Containerize! Between Docker and Jube.
Containerize! Between Docker and Jube.Containerize! Between Docker and Jube.
Containerize! Between Docker and Jube.
Henryk Konsek
 
Docker n co
Docker n coDocker n co
Docker n co
Rohit Jnagal
 
A Docker Diagram
A Docker DiagramA Docker Diagram
A Docker Diagram
YangJerng Hwa
 
Docker 102 - Immutable Infrastructure
Docker 102 - Immutable InfrastructureDocker 102 - Immutable Infrastructure
Docker 102 - Immutable Infrastructure
Adrian Otto
 
Red Hat Enterprise Linux OpenStack Platform 7 - VM Instance HA Architecture
Red Hat Enterprise Linux OpenStack Platform 7 - VM Instance HA ArchitectureRed Hat Enterprise Linux OpenStack Platform 7 - VM Instance HA Architecture
Red Hat Enterprise Linux OpenStack Platform 7 - VM Instance HA Architecture
Etsuji Nakai
 
LXC, Docker, security: is it safe to run applications in Linux Containers?
LXC, Docker, security: is it safe to run applications in Linux Containers?LXC, Docker, security: is it safe to run applications in Linux Containers?
LXC, Docker, security: is it safe to run applications in Linux Containers?
Jérôme Petazzoni
 
Docker: Please contain your excitement
Docker: Please contain your excitementDocker: Please contain your excitement
Docker: Please contain your excitement
johnnnl
 
Containers - What are they and Atomic
Containers - What are they and AtomicContainers - What are they and Atomic
Containers - What are they and Atomic
Syed Shaaf
 
Docker 101 2015-05-28
Docker 101 2015-05-28Docker 101 2015-05-28
Docker 101 2015-05-28
Adrian Otto
 
Containers are the future of the Cloud
Containers are the future of the CloudContainers are the future of the Cloud
Containers are the future of the Cloud
Pavel Odintsov
 
Lxc – next gen virtualization for cloud intro (cloudexpo)
Lxc – next gen virtualization for cloud   intro (cloudexpo)Lxc – next gen virtualization for cloud   intro (cloudexpo)
Lxc – next gen virtualization for cloud intro (cloudexpo)
Boden Russell
 
Docker 1.11 @ Docker SF Meetup
Docker 1.11 @ Docker SF MeetupDocker 1.11 @ Docker SF Meetup
Docker 1.11 @ Docker SF Meetup
Docker, Inc.
 
Linuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best PracticesLinuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best Practices
christophm
 
What's really the difference between a VM and a Container?
What's really the difference between a VM and a Container?What's really the difference between a VM and a Container?
What's really the difference between a VM and a Container?
Adrian Otto
 
Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby
Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby
Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby
Michelle Antebi
 
Octo talk : docker multi-host networking
Octo talk : docker multi-host networking Octo talk : docker multi-host networking
Octo talk : docker multi-host networking
Hervé Leclerc
 
Linux Container Technology 101
Linux Container Technology 101Linux Container Technology 101
Linux Container Technology 101
inside-BigData.com
 
Containerize! Between Docker and Jube.
Containerize! Between Docker and Jube.Containerize! Between Docker and Jube.
Containerize! Between Docker and Jube.
Henryk Konsek
 

Similar to Isolating an applications using LXC – Linux Containers (20)

Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant
Ricardo Amaro
 
Evolution of containers to kubernetes
Evolution of containers to kubernetesEvolution of containers to kubernetes
Evolution of containers to kubernetes
Krishna-Kumar
 
Lightweight Virtualization in Linux
Lightweight Virtualization in LinuxLightweight Virtualization in Linux
Lightweight Virtualization in Linux
Sadegh Dorri N.
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
Kevin Littlejohn
 
Drupalcamp es 2013 drupal with lxc docker and vagrant
Drupalcamp es 2013  drupal with lxc docker and vagrant Drupalcamp es 2013  drupal with lxc docker and vagrant
Drupalcamp es 2013 drupal with lxc docker and vagrant
Ricardo Amaro
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux Container
Balaji Rajan
 
Dev opsec dockerimage_patch_n_lifecyclemanagement_2019
Dev opsec dockerimage_patch_n_lifecyclemanagement_2019Dev opsec dockerimage_patch_n_lifecyclemanagement_2019
Dev opsec dockerimage_patch_n_lifecyclemanagement_2019
kanedafromparis
 
The State of Linux Containers
The State of Linux ContainersThe State of Linux Containers
The State of Linux Containers
inside-BigData.com
 
Linux Containers & Docker
Linux Containers & DockerLinux Containers & Docker
Linux Containers & Docker
Jumping Bean
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
PROIDEA
 
Understanding LXC & Docker
Understanding LXC & DockerUnderstanding LXC & Docker
Understanding LXC & Docker
Comprinno Technologies
 
Security of Linux containers in the cloud
Security of Linux containers in the cloudSecurity of Linux containers in the cloud
Security of Linux containers in the cloud
Dobrica Pavlinušić
 
Using Docker with OpenStack - Hands On!
 Using Docker with OpenStack - Hands On! Using Docker with OpenStack - Hands On!
Using Docker with OpenStack - Hands On!
Adrian Otto
 
Develop QNAP NAS App by Docker
Develop QNAP NAS App by DockerDevelop QNAP NAS App by Docker
Develop QNAP NAS App by Docker
Terry Chen
 
Docker Ecosystem on Azure
Docker Ecosystem on AzureDocker Ecosystem on Azure
Docker Ecosystem on Azure
Patrick Chanezon
 
Develop with linux containers and docker
Develop with linux containers and dockerDevelop with linux containers and docker
Develop with linux containers and docker
Fabio Fumarola
 
ExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ExpoQA 2017 Using docker to build and test in your laptop and JenkinsExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ElasTest Project
 
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Brown Bag - Vagrant & Docker: IntroductionAgile Brown Bag - Vagrant & Docker: Introduction
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Partner S.A.
 
Docker Security
Docker SecurityDocker Security
Docker Security
BladE0341
 
Docker Athens: Docker Engine Evolution & Containerd Use Cases
Docker Athens: Docker Engine Evolution & Containerd Use CasesDocker Athens: Docker Engine Evolution & Containerd Use Cases
Docker Athens: Docker Engine Evolution & Containerd Use Cases
Phil Estes
 
Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant
Ricardo Amaro
 
Evolution of containers to kubernetes
Evolution of containers to kubernetesEvolution of containers to kubernetes
Evolution of containers to kubernetes
Krishna-Kumar
 
Lightweight Virtualization in Linux
Lightweight Virtualization in LinuxLightweight Virtualization in Linux
Lightweight Virtualization in Linux
Sadegh Dorri N.
 
Drupalcamp es 2013 drupal with lxc docker and vagrant
Drupalcamp es 2013  drupal with lxc docker and vagrant Drupalcamp es 2013  drupal with lxc docker and vagrant
Drupalcamp es 2013 drupal with lxc docker and vagrant
Ricardo Amaro
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux Container
Balaji Rajan
 
Dev opsec dockerimage_patch_n_lifecyclemanagement_2019
Dev opsec dockerimage_patch_n_lifecyclemanagement_2019Dev opsec dockerimage_patch_n_lifecyclemanagement_2019
Dev opsec dockerimage_patch_n_lifecyclemanagement_2019
kanedafromparis
 
Linux Containers & Docker
Linux Containers & DockerLinux Containers & Docker
Linux Containers & Docker
Jumping Bean
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
PROIDEA
 
Security of Linux containers in the cloud
Security of Linux containers in the cloudSecurity of Linux containers in the cloud
Security of Linux containers in the cloud
Dobrica Pavlinušić
 
Using Docker with OpenStack - Hands On!
 Using Docker with OpenStack - Hands On! Using Docker with OpenStack - Hands On!
Using Docker with OpenStack - Hands On!
Adrian Otto
 
Develop QNAP NAS App by Docker
Develop QNAP NAS App by DockerDevelop QNAP NAS App by Docker
Develop QNAP NAS App by Docker
Terry Chen
 
Develop with linux containers and docker
Develop with linux containers and dockerDevelop with linux containers and docker
Develop with linux containers and docker
Fabio Fumarola
 
ExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ExpoQA 2017 Using docker to build and test in your laptop and JenkinsExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ElasTest Project
 
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Brown Bag - Vagrant & Docker: IntroductionAgile Brown Bag - Vagrant & Docker: Introduction
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Partner S.A.
 
Docker Security
Docker SecurityDocker Security
Docker Security
BladE0341
 
Docker Athens: Docker Engine Evolution & Containerd Use Cases
Docker Athens: Docker Engine Evolution & Containerd Use CasesDocker Athens: Docker Engine Evolution & Containerd Use Cases
Docker Athens: Docker Engine Evolution & Containerd Use Cases
Phil Estes
 
Ad

Recently uploaded (20)

AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Ad

Isolating an applications using LXC – Linux Containers

  • 1. Isolating an applications using LXC – Linux Containers Linux Containers have got huge attention lately due to high demand and business shifting towards cloud computing and virtualization. Linux Containers are the process level based virtualization which uses the same operating system kernel. The main advantage of LXC is the lightweight when compared to the traditional Hardware based virtualization (KVM) and Xen. The Idea of containers was implemented by Solaris Zones as well as BSD jails quite a few years ago. However, they required custom kernels, which was often a major setback. LXC uses these kernel features:  Kernel namespaces (ipc, uts, mount, pid, network, and user)  AppArmor and SELinux profiles  Seccomp policies  Chroots (using pivot_root)  Kernel capabilities  Control groups (cgroups). Namespaces: Namespaces provide the first, and most straightforward, form of isolation: processes running within a container cannot see, and even less affect, processes running in another container, or in the host system. Control Groups: cgroups are the key components in the Linux Containers. They take care of resource allocation of memory, CPU, disk I/O. LXC shares the equal amount of memory or CPU resources across multiple containers. This plays a major role where Nesting of Linux Containers are implemented. Installing containers: Containers can be installed as other applications. The table below specifies the way of installing, configuring and running application in containers. ~>Installing Container apt-get install lxc Create an "Ubuntu" based container named cn-01. This will download set of files form internet for the first time. There are some predefined container templateto create as Alpine Linux, Alt Linux, Arch Linux, busybox, CentOS, Cirros, Debian, Fedora, OpenMandriva, OpenSUSE, Oracle, Plamo, sshd, Ubuntu Cloud and Ubuntu. lxc-create -t ubuntu -n cn-01 ~>check the contaibers config as: lxc-checkconfig
  • 2. Isolating an applications using LXC – Linux Containers ~> Start the container (in the background) lxc-start -n cn-01 -d ~>Check the container status as below to get the status and IP address of the container: lxc-ls --fancy ~>Enter the container in one of those ways## Attach to the container's console (ctrl-a + q to detach) lxc-console -n p1 ~>SSH into it ssh ubuntu@<ip from lxc-info> ~>Stop the container in one of those ways poweroff ~>Stop it cleanly from the outside lxc-stop -n cn-01 ~>Kill it from the outside lxc-stop -n cn-01 -k Installing application inside Container -1: As an example we shall install apache2 web server inside the container which can be accessed in the host machine. sudo apt-get install apache2 Checking LXC configs
  • 3. Isolating an applications using LXC – Linux Containers Getting into LXC console: sdf sdf ffsdfsdf SSH login into container: Installing Apache in the container:
  • 4. Isolating an applications using LXC – Linux Containers Once the Apache has been configured and up and running it can be viewable via host browser as below
  • 5. Isolating an applications using LXC – Linux Containers The container info can be retrieved using the below command as such. Container Configuration: Services such as Network, resource allocation (memory, CPU etc) can be configured in “/var/lib/lxc/<container-name>config” Hooks: Hooks are the useful and convenient way to run custom scripts inside the containers. There are different types of hooks which can be invoked.  lxc.hook.pre-start (calledbefore any initialization is done)  lxc.hook.pre-mount (calledafter creating the mount namespace but before mounting anything)  lxc.hook.mount (called after the mounts but before pivot_root)  lxc.hook.autodev (identical to mount but only called if using autodev)
  • 6. Isolating an applications using LXC – Linux Containers  lxc.hook.start (called in the container right before /sbin/init)  lxc.hook.post-stop (run after the container has been shutdown)  lxc.hook.clone (calledwhen cloning a container into a new one) Additionally each network section may also define two additional hooks:  lxc.network.script.up (calledin the network namespace after the interface was created)  lxc.network.script.down (called in the network namespace before destroying the interface) Example for creating a pre-start hook script. lxc.hook.pre-start = /var/lib/lxc/<container-name>/pre-start.sh The container can be deleted or destroyed once the container purpose has solved. lxc-shutdown -n cn-01 Once the container gets shutdown and it is ready to be destroyed once the necessary data has been backed up, lxc-destory -n cn-01. Installing application inside Container -2: As an example, we can install Kali Linux and Metasploit inside a container and we can use kali Linux via web browser using OpenBox and NoVNC. I have tried this example via kali Linux. Please find the steps involved in this to install and configure Docker under kali Linux. apt-get update apt-get -y install docker.io ln -sf /usr/bin/docker.io /usr/local/bin/docker Finally, and optionally, let’s configure Docker to start when the server boots: update-rc.d docker.io defaults service docker start Once the docker service is up and running, we can use pull docker meta images (smaller footprint) as below. docker pull kalilinux/kali-linux-docker Once the initial set up of the kali Linux within Docker gets completed, we can start installing
  • 7. Isolating an applications using LXC – Linux Containers Metasploit inside the docker. docker run -t -i -p 6080:6080 kalilinux/kali-linux-docker /bin/bash You will be welcomed within kali linux inside the docker with a command prompt. You can further start installing Metasploit package as below. apt-get install metasploit Building Your Own Kali Linux Docker Image If you want to build your own Kali images rather than use our pre-made ones, we’ve made it easy with the following script hosted on Kali Linux Docker on Github. These images are best built on a Linux system or any other OS that can debootstrap. #!/bin/bash # Install dependencies (debbootstrap) sudo apt-get install debootstrap # Fetch the latest Kali debootstrap script from git curl "http://git.kali.org/gitweb/?p=packages/debootstrap.git;a=blob_plain;f=scripts/kali;hb=HEA D" &gt; kali-debootstrap &amp;&amp; sudo debootstrap kali ./kali-root http://http.kali.org/kali ./kali-debootstrap &amp;&amp; # Import the Kali image into Docker sudo tar -C kali-root -c . | sudo docker import - kalilinux/kali &amp;&amp; sudo rm -rf ./kali-root &amp;&amp; # Test the Kali Docker Image docker run -t -i kalilinux/kali cat /etc/debian_version &amp;&amp; echo "Build OK" || echo "Build failed!" Configuring Openbox and noVNC: Openbox and noVNC can be downloaded from below paths and configure accordingly. noVNC: https://github.com/kanaka/noVNC Openbox: http://openbox.org/wiki/Main_Page Conclusion: We have covered the basics of the Container concepts from installing, configuring and running an application inside the container. Dockers are built on top of LXC. In Dockers case, its advantage is that its open-source engine can be used to pack, ship, and run any application as a lightweight, portable, self-sufficient LXC container that runs virtually anywhere. It’s a packaging system for applications.