-
-
Save sebastienvg/8c8ed6e44607a1407ecf930d73866550 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The best distro for LXC right now is ubuntu since you'll have almost no config to get LXC networking working | |
# All LXC commands have to be run as root (or sudo) | |
# 1. DO IT once on the host | |
# 1.1 install lxc | |
apt-get install lxc | |
# 1.2 enable nat on iptables | |
echo 1 > /proc/sys/net/ipv4/ip_forward | |
# 2. DO IT for every project you want a container for | |
# 2.1 | |
lxc-create -t download -n my_project | |
# 2.2 if you want to share project's source (or maybe logs folder) with the host, sourceedit /var/lib/lxc/my_project/config and add the following | |
lxc.mount.entry = /home/user/Workspace/my_project my_project none default,bind 0 0 | |
# 2.3 if you want to make available throught the host, execute the following (adapt the IP and PORT) and persist it! | |
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport {PORT} -j DNAT --to {IP}:{PORT} | |
# 3. DO IT every time you want | |
# 3.1 start your container | |
lxc-start -n my_project | |
# 3.2 if you need a shell, attach to the container | |
lxc-attach -n my_project | |
# 3.3 stop the container once you're done | |
lxc-stop -n my_project |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment