[lxc-users] lxd: getting rid of the initial network interface

Frans Meulenbroeks fransmeulenbroeks at gmail.com
Sun Feb 12 18:16:07 UTC 2017


Hi Stéphane,

Thanks for your reply.
That explains things.

If you pardon the n00b I have a few more additional questions:

I've been struggling to add an interface using the REST API while copying a
container, but as far as I can judge if I copy an image I cannot add
devices. Right?

Also I've tried to make an image from a loclal container (again using the
rest api).
This doc:https://github.com/lxc/lxd/blob/master/doc/rest-api.md
suggests using this dict:

{
    "compression_algorithm": "xz",  # Override the compression
algorithm for the image (optional)
    "filename": filename,           # Used for export (optional)
    "public":   true,               # Whether the image can be
downloaded by untrusted users (defaults to false)
    "properties": {                 # Image properties (optional)
        "os": "Ubuntu"
    },
    "source": {
        "type": "container",        # One of "container" or "snapshot"
        "name": "abc"
    }
}

I tried this without any of the optional fields, but somehow no new image
is made.
(I was also wondering if I could name the image one way or another)

Thanks, Frans

2017-02-12 18:45 GMT+01:00 Stéphane Graber <stgraber at ubuntu.com>:

> On Sun, Feb 12, 2017 at 10:01:17AM +0100, Frans Meulenbroeks wrote:
> > Hi,
> >
> > I want to get rid of the network interface that my container has, but
> > somehow I can't figure out how to get that done.
> >
> > I have created a new container from scratch with:
> > lxc launch ubuntu:14.04 my-ubuntu
> >
> > lxc config show my-ubuntu gives;
> >
> > architecture: x86_64
> > config:
> >   image.architecture: amd64
> >   image.description: ubuntu 14.04 LTS amd64 (release) (20170202.1)
> >   image.label: release
> >   image.os: ubuntu
> >   image.release: trusty
> >   image.serial: "20170202.1"
> >   image.version: "14.04"
> >   volatile.base_image:
> > 3b825a6a063aacc6b19df84f7ddc4fe872a0e382ec0bb92f475a9493b0857e01
> >   volatile.eth0.hwaddr: 00:16:3e:25:48:06
> >   volatile.idmap.base: "0"
> >   volatile.idmap.next:
> > '[{"Isuid":true,"Isgid":false,"Hostid":231072,"Nsid":0,"
> Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":
> 231072,"Nsid":0,"Maprange":65536}]'
> >   volatile.last_state.idmap:
> > '[{"Isuid":true,"Isgid":false,"Hostid":231072,"Nsid":0,"
> Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":
> 231072,"Nsid":0,"Maprange":65536}]'
> >   volatile.last_state.power: RUNNING
> > devices:
> >   root:
> >     path: /
> >     type: disk
> > ephemeral: false
> > profiles:
> > - default
>
> That shows that your container is inheriting from the "default" profile
> which likely does include that eth0 device.
>
>     lxc config show --expanded my-ubuntu
>
> Would show you the config with the profiles applied.
>
> To remove something that's inherited from a profile, you have to mask it
> with something like:
>
>     lxc config device add my-ubuntu eth0 none
>
> Which masks the inherited device "eth0" with an empty one.
>
> > Note: no nic device, but there is a volatile.eth0.hwaddr address
> >
> > And if I look into the container with lxc exec my-ubuntu --  ifconfig -a
> >
> > eth0      Link encap:Ethernet  HWaddr 00:16:3e:25:48:06
> >           inet addr:10.202.122.138  Bcast:10.202.122.255
> Mask:255.255.255.0
> >           inet6 addr: fe80::216:3eff:fe25:4806/64 Scope:Link
> >           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
> >           RX packets:95 errors:0 dropped:0 overruns:0 frame:0
> >           TX packets:74 errors:0 dropped:0 overruns:0 carrier:0
> >           collisions:0 txqueuelen:1000
> >           RX bytes:19120 (19.1 KB)  TX bytes:7960 (7.9 KB)
> >
> > lo        Link encap:Local Loopback
> >           inet addr:127.0.0.1  Mask:255.0.0.0
> >           inet6 addr: ::1/128 Scope:Host
> >           UP LOOPBACK RUNNING  MTU:65536  Metric:1
> >           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
> >           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
> >           collisions:0 txqueuelen:1
> >           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
> >
> > And if I do lxc network show lxdbr0 I see that the container is using the
> > bridge.
> >
> > $ lxc network show lxdbr0
> > config:
> >   dns.mode: dynamic
> >   ipv4.address: 10.202.122.1/24
> >   ipv4.dhcp.ranges: 10.202.122.2-10.202.122.254
> >   ipv4.nat: "true"
> >   ipv6.address: none
> > name: lxdbr0
> > type: bridge
> > usedby:
> > ...
> > - /1.0/containers/my-ubuntu
> > ...
> > managed: true
> >
> >
> > ButI cannot remove the device from the bridge:
> >
> > lxc network detach lxdbr0 my-ubuntu
> > error: No device found for this network
> >
> > Is there a way to get rid of this interface?
> >
> > (actually I want to attach eth0 to a different bridge)
>
> To attach it to a different bridge, you'll want to mask the inherited
> "eth0" with another eth0 that's attached to the bridge you want:
>
>
>     lxc config device add my-ubuntu eth0 nic nictype=bridged
> parent=new-bridge
>
>
> Or on recent LXD, this will achieve the same:
>
>     lxc network attach new-bridge my-ubuntu eth0
>
> >
> > Thanks in advance!
> > Frans
>
> > _______________________________________________
> > lxc-users mailing list
> > lxc-users at lists.linuxcontainers.org
> > http://lists.linuxcontainers.org/listinfo/lxc-users
>
>
> --
> Stéphane Graber
> Ubuntu developer
> http://www.ubuntu.com
>
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20170212/5620c595/attachment.html>


More information about the lxc-users mailing list