Linux container cheat sheet #lxc

Mar 31, 2016 · 3 min read

About linux containers

Linux containers(lxc) are lightweight operating system level virtualization technology. Unlike some hardware level virtualization solutions(virtual machines), no hardware emulation is used in containers. All all the containers shares the kernel as well as the resources such as CPU, RAM, Hard disk, and network etc of the original host machine.

I have written some posts regarding Virtualization and Linux Containers. You can find more information about operating system level virtualization and linux containers from there.

Cheat sheet

Following are the basic/main commands to install and manage linux containers(lxc)


Check configurations

Create container

List containers

Start container

View container info

Connect to container

SSH to container

Stop container

Delete container

Install mongodb via lxc

In order to install mongodb via lxc, first we have to create lxc container then needs to connect to it(via ssh or lxc-console) and install the mongodb. After installing mongodb inside the container, we can connect to it from host machine via container ip and mongodb port.

Create and connect to container

Install mongodb inside the container

After installing we can connect to mongodb from(with in) inside the container via default host(localhost) and default port(27017)

Allow to connect mongodb from outside the container

By default mongodb allow to connect via localhost. It restricted via mongodb config file’s(in /etc/mongodb.conf) bindIp field(Bind IP is a MongoDB option that restricts connections to specifics IPs)

In order to connect mongodb(installed in the mongodb container) from other hosts(for an example from another container or from host machine) we have to set the bindIp field to mongodb container ip.

After setting the bindIp, needs to restart the mongodb service

Connect mongodb from host machine

In order to connects to mongodb from host machine, host machine needs to have install the mongodb shell.

Now we can connects to mongodb installed in mongodb container from the host machine.

Container storage

On ubuntu by default each container has a directory in

Containers configurations and root file system(rootfs) stored in this directory

Container config

Container configurations stored in the config in

Container rootfs

Containers root file system stored in


Have less, be more


Written by


Ego = 1/Knowledge


Have less, be more

More From Medium

More on DevOps from Rahasak-Labs

More on DevOps from Rahasak-Labs

Openstack Swift Scala Client

Mar 20 · 2 min read


More on DevOps from Rahasak-Labs

More on DevOps from Rahasak-Labs

Minio object storage scala client

Mar 20 · 3 min read


More on DevOps from Rahasak-Labs

More on DevOps from Rahasak-Labs

Cassandra-Reaper in Sidecar mode

Mar 18 · 4 min read
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade