[lxc-users] Networking in LXC

Ajith Adapa ajith.adapa at gmail.com
Tue Jun 10 11:39:28 UTC 2014


Thanks for the reply @Fajar.

(From Host)
# lxc-attach -n root -- echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

(Inside container)
# ifconfig
-bash: ifconfig: command not found
# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

As you mentioned there is a difference in PATH. I am using default
config to create a lxc container. Is it an issue with fedora or we
have to manually set it everytime a container is created ?

================================================

I have a doubt regarding binding a physical interface to a lxc-container.

As per the instructions provided, we are creating a file at /run/netns
say user1 and then attaching interfaces to the network namespace user1
using ip command. Then we are using mount command to mount the network
namespace user1 in the process.

If I restart the container then the container starts with the new
process-id. Then if I try to mount the same network namespace user1 to
new process I am not seeing the physical interfaces inside the
container.

Should I delete the network-namespace user1 when the container is
stopped and create it again when we restart the container to make it
work ?

Regards,
Ajith



On Tue, Jun 10, 2014 at 2:48 PM, Fajar A. Nugraha <list at fajar.net> wrote:
> 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
> _______________________________________________
> 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