[lxc-users] Networking in LXC

Fajar A. Nugraha list at fajar.net
Tue Jun 10 09:18:14 UTC 2014


On Tue, Jun 10, 2014 at 3:12 PM, Ajith Adapa <ajith.adapa at gmail.com> wrote:
> Hi,
>
> First I need to really thank the community for helping me out in
> starting LXC container on fedora 20.
>
> I have some basic questions regarding networking in LXC.
>
> 1. Is there any tutorial or doc regarding support for various network
> options in lxc container ?

Probably http://manpages.ubuntu.com/manpages/trusty/man5/lxc.container.conf.5.html
?

IIRC Fedora rawhide has lxc 1.0.3, so if you update to that you should
have the same manpage. Otherwise you'd still be using lxc-0.9.0 which
might be missing some features.

>
> 2. When I login into container and try ifconfig command I am getting
> error saying "command not found" but I am able to run the same command
> using lxc-attach. Any reason why ?
>

incorrect PATH? Try

(from the host) lxc-attach -n CONTAINER_NAME -- echo $PATH
(inside the container) echo $PATH

in your case those two should display different output

> 3. Is it possible to attach a physical interface to lxc container
> which is in running state ? Currently we need to set the configuration
> in the config file and restart the container.

There's probably an easier way. The long way would be like this:

# lxc-start -d -n template

# lxc-info -n template
Name:           template
State:          RUNNING
PID:            8320  <= this is what we need, the PID of a process
inside the container
CPU use:        0.93 seconds
BlkIO use:      6.28 MiB
Memory use:     18.72 MiB
KMem use:       0 bytes
Link:           vethDUGP01
 TX bytes:      1.24 KiB
 RX bytes:      84 bytes
 Total bytes:   1.32 KiB

# mkdir -p /run/netns

# touch /run/netns/8320 <= this one could be any name you want, which
would then be used by "ip ... netns"

# mount --bind /proc/8320/ns/net /run/netns/8320

# ip link show dummy1
8: dummy1: <BROADCAST,NOARP> mtu 1500 qdisc noqueue state DOWN mode
DEFAULT group default
    link/ether 76:c6:a2:7f:c6:57 brd ff:ff:ff:ff:ff:ff

# ip link set dummy1 netns 8320

# ip link show dummy1
Device "dummy1" does not exist.

# lxc-attach -n template -- ip link show dummy1
8: dummy1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode
DEFAULT group default
    link/ether 76:c6:a2:7f:c6:57 brd ff:ff:ff:ff:ff:ff


-- 
Fajar

>
> Regards,
> Ajith
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users


More information about the lxc-users mailing list