Skip to content

Instantly share code, notes, and snippets.

@erangaeb
erangaeb / lxc_start
Last active March 31, 2016 14:50
Start lxc container
# command
sudo lxc-start -n <container-name> -d
# example
sudo lxc-start -n mongodb -d
# -d will start contaier as deamon
@erangaeb
erangaeb / lxc_info
Created March 31, 2016 14:43
View lxc container information
# command
sudo lxc-info -n <container-name>
# example
sudo lxc-info -n mongodb
@erangaeb
erangaeb / lxc_console
Last active March 31, 2016 15:01
Connect to lxc container
# command
sudo lxc-connect -n <container-name>
# example
sudo lxc-connect -n mongodb
# It will ask for username/password,
# default username - ubuntu
# default passowrd - ubuntu
@erangaeb
erangaeb / lxc_ssh
Created March 31, 2016 14:53
SSH to container
# connect as normal ssh session
ssh <user>@<container-ip>
# example
ssh [email protected]
# container ip can be find via container information
@erangaeb
erangaeb / lxc_stop
Created March 31, 2016 15:00
Stop container
# From host machine
sudo lxc-stop -n <container-name>
sudo lxc-stop -n mongodb
# From inside container(after connecting via ssh or lxc-console)
sudo poweroff
@erangaeb
erangaeb / lxc_destroy
Created March 31, 2016 15:04
Delete container
# command
sudo lxc-destroy -n <container-name>
# example
sudo lxc-destroy -n mongo
@erangaeb
erangaeb / lxc_mongo
Created March 31, 2016 15:14
Mongo db lxc container
# create container
sudo lxc-create -n mongo -t ubuntu
# connect to container
ssh [email protected]
@erangaeb
erangaeb / lxc_install_mongodb
Last active February 23, 2024 14:12
Install mongodb in lxc container
# GPG keys
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
# list file for MongoDB
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
# install
sudo apt-get update
sudo apt-get install -y mongodb-org
@erangaeb
erangaeb / mongodb_restart
Created March 31, 2016 15:41
Restart mongo db service
sudo service mongod restart
# or
sudo service mongod stop
sudo service mongod start
@erangaeb
erangaeb / install_mongodb_shell
Created March 31, 2016 15:43
Install mongodb shell
sudo apt-get install mongodb-org-shell