InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Ubuntu tutorials

  • How to add a user on Linux with sudo access
  • How to check if a user has password on Linux
  • How to install ViewVC for svn repository on Ubuntu Linux
  • How to setup ssl (https) for your site on Ubuntu Linux
  • Install rabbitmq on Ubuntu Linux
  • LXC (Linux Containers) - quick start tutorial on Ubuntu
  • Linux - command to check swap size
  • Linux - how to add a user using useradd
  • Linux - how to create a large file like 1GB
  • Linux - how to create swap partition
  • Linux - how to remove user from a group
  • Linux - number of cpus (lscpu)
  • Linux du - find disk usage of directories or files
  • NFS client and server handy commands
  • Setup svn repository on AWS Ubuntu with apache auth
  • Ubuntu - check if a service is upstart based
  • Ubuntu - dpkg and apt-get beginner tutorial
  • Ubuntu - find file to package
  • Ubuntu - find where will a package be installed from
  • Ubuntu - how to auto start services on boot using update-rc.d (sysv init)
  • Ubuntu - how to find boot autostart status of a service
  • Ubuntu - reload iptables rules during boot
  • Use x2go to access remote Ubuntu Linux
 
  • Home
  • > Tutorials
  • > Linux

LXC (Linux Containers) – quick start tutorial on Ubuntu

By admin on Jan 18, 2016

LXC (Linux Containers) is an operating-system-level virtualization environment for running multiple isolated Linux systems (containers) on a single Linux control host. Here is a quick start guide for getting started with lxc on Ubuntu Linux.

lxc-linux-container-tutorial

  1. First install lxc package
    $ sudo apt-get install lxc
    
  2. Create a container (ubuntu trusty release)

    $ sudo lxc-create -t download -n ubuntu-test -- --dist ubuntu --release trusty --arch amd64
    
  3. List existing containers.

    $ sudo lxc-ls --fancy
    NAME         STATE    IPV4  IPV6  AUTOSTART  
    -------------------------------------------
    ubuntu-test  STOPPED  -     -     NO  
    
  4. Start the container

    $ sudo lxc-start --name ubuntu-test --daemon
    
  5. In case you need to stop and or destroy container

    $ sudo lxc-stop -n ubuntu-test
    $ sudo lxc-destroy -n ubuntu-test
    
  6. List existing containers again

    $ sudo lxc-ls --fancy
    NAME         STATE    IPV4       IPV6  AUTOSTART  
    ------------------------------------------------
    ubuntu-test  RUNNING  10.0.3.54  -     NO 
    
  7. Display info about container using name

    sudo lxc-info --name ubuntu-test
    Name:           ubuntu-test
    State:          RUNNING
    PID:            7629
    IP:             10.0.3.54
    CPU use:        0.64 seconds
    BlkIO use:      1.62 MiB
    Memory use:     7.79 MiB
    KMem use:       0 bytes
    Link:           veth4WTBQP
     TX bytes:      3.25 KiB
     RX bytes:      3.38 KiB
     Total bytes:   6.64 KiB
    
  8. Install python on the container

    $ sudo lxc-attach --name ubuntu-test -- sudo apt-get install python
    
  9. Run python hello world on the container

    $ sudo lxc-attach --name ubuntu-test -- python -c "print \"Hello\""
    
  10. Run shell on container

    $ sudo lxc-attach --name ubuntu-test
    root@ubuntu-test:/# ls
    bin  boot  dev	etc  home  lib	lib64  media  mnt  opt	proc  root  run  sbin  srv  sys  tmp  usr  var
    

Suggested posts:

  1. Python re search vs match
  2. document querySelector examples
  3. How to use wildcard in robots.txt
  4. Centos/RHEL – find package for a file
  5. Ngrep – quick start guide
  6. Setup xdebug for remote wordpress debugging
  7. Docker how to add a user to group docker on Linux
  8. How to use phantomjs to create site/url snapshot thumbnail
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Linux, Tutorials, Ubuntu Linux
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress