Skip to main content

Posts

Showing posts from July, 2015

archlinux lxc debian centos container

Create Debian8 and CentOS7 LXC containers on Archlinux host Using LXC to create Debian 8 and CentOS 7 containers require to play with AUR.

In order to ease the work:

# pacman -S base-devel

In  /etc/pacman.conf
[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/$arch

# pacman -S lxcarch-install-scripts netctl # pacman -S yaourt $ yaourt -S debootstrap yum
This last command will pull several packages from AUR then expect some long time compiling I dont really know why, but I had to reboot to have everything working smoothly.
Create a CentOS7 container
# export CONTAINER_NAME=c7-00 # lxc-create  -t centos --name ${CONTAINER_NAME} -- --release 7 --arch x86_64 \
               --repo YOU_CUSTOM_REPO
Then edit the configuration: # nano -w /var/lib/lxc/${CONTAINER_NAME}/config
Mine looks like this
lxc.rootfs = /var/lib/lxc/c7-00/rootfs lxc.include = /usr/share/lxc/config/centos.common.conf lxc.arch = x86_64 lxc.utsname = c7-00 lxc.network.type = veth lxc.network.flags = up lxc.network.link = br…

archlinux switch to bridge network

Switch from normal networking to bridged Just after installation, you need to run networking on a traditional way in order to make initial setup (some needed packages like SSH, netctl,...)

"Traditional networking" is here to use the "ethN" or "enoZZZZZ" interface and assign an IP to that interface.

But if you want to switch to bridged one, you need to disable that traditional setting and activate the bridged one.
Traditional settingInterface name: eth0Address assignation: static/etc/systemd/network/wired.network

[Match]
Name=eth0 [Network]  DNS=192.168.128.108 [Address] Address=192.168.129.148/23 [Route] Gateway=192.168.128.108
Start "systemd-networkd.service" # systemctl start systemd-networkd
To enable it at boot, # systemctl enable systemd-networkd Switch to bridged setting # pacman -S netctl
/etc/netctl/lxcbridge Description="LXC bridge" Interface=br0 Connection=bridge BindsToInterfaces=('eth0') IP=static Address=192.168.129.148/23 Gateway…

docker network centos debian

Docker Network configuration on Debian 8 and CentOS 7
My configuration is to run a full VM and then launch several containers on it.
Tha VM can be a CentOS or a Debian.
As of writing, current versions are Debian 8 and CentOS 7

Debian 8 You can decide what subnet you want the containers work in.
Default is "172.17.0.0/16", and the "docker0" belongs to that range.
By setting up the "--bip" option in "/etc/default/docker" you can force "docker0" range:

DOCKER_OPTS=" --bip=172.17.250.1/24 "
CentOS 7
CentOS has a slightly different configuration layout.
By setting up the "--bip" option in "/etc/sysconfig/docker-network" you can force "docker0" range:

DOCKER_NETWORK_OPTIONS=" --bip=172.17.250.1/24 "

docker discovery usefull commands

Some usefull commands and settings when using docker# docker login Will create a .dockercfg file which is reusable on other hosts
Usefull if you choosed a PITA username and password, like I did.
# docker pull xxx # docker --name zzz run xxx:yyy Can be chortened as
# docker run --name zzz [...] xxx:yyy It will pull for you.
If the container zzz ever stopped
# docker start zzz Show the full parameters of a container
# docker inspect zzz You'll see it's a JSON file, and if you just want to print some parameters:
# docker inspect --format '{{.NetworkSettings.IPAddress}}' zzz