Cloned Container and IP

So I cloned a container, activated it, installed a Letsencrypt SSL cert.
The problem I am having is it has the same IP as the container I cloned!

How do I fix that?

Thanks

Ray

So I shut down the original container. Now the cloned container is failing at my Haproxy. Here is the failure:

I shut down the original container (patriots), but now Haproxy is giving me the following error:
root@HAProxy:/etc/haproxy# sudo /usr/sbin/haproxy -c -V -f /etc/haproxy/haproxy.cfg

[ALERT] 325/182048 (5552) : parsing [/etc/haproxy/haproxy.cfg:129] : ā€˜server patriotsplaceā€™ : could not resolve address ā€˜patriotsplace.lxdā€™.
[ALERT] 325/182048 (5552) : Failed to initialize server(s) addr.

Here is my haproxy config for the patriotsplace container:
frontend http_lb
acl patriotspl hdr(host) -i patriotsplace.streamingworld.us
use_backend patriots2 if patriotspl

backend patriots2
http-request set-header X-Client-IP %[src]
redirect scheme https if ! { ssl_fc }
server patriotsplace patriotsplace.lxd:80 check

A similar config for the original container works fine.

I posted this at the Haproxy community and was told this is not an Haproxy issue.

Ray

$ host patriotsplace.lxd
$ Host patriotsplace.lxd not found: 3(NXDOMAIN)

Any idea how to fix?

Hi Rayj,
Lets go step by step and understand the problem, what is the output of the lxc ls command? What you are going to achieve?
Regards.

Are you using LXD or LXC?
How did you clone the container?

LXD/LXC v3.0.3 on Ubuntu 20.04

So I have the original container ā€œbroadcastā€ which works fine and does what I want.

Now I wanted to incorporate the applications in broadcast into another container called patriotsplace.
To do that, I cloned the broadcast container to patriotsplace so I have a container I can experiment with, with the goal to add additional functionality.

To clone I did: lxc copy broadcast patriotsplace
It cloned fine, but I ended up with this:

Note the duplicate IPā€™s?

When I am in the patriotsplace container:
$ host patriotsplace.lxd
$ Host patriotsplace.lxd not found: 3(NXDOMAIN)

When I am in the broadcast container:
$ host broadcast.lxd
$ broadcast.lxd has address 10.90.200.61

So the container contents are not an issue. It appears to be an issue in the ā€œcopyā€ process?
The question is how to fix patriotsplace ā€œnot foundā€ issue?

Thanks

Ray

Please can you show the output of lxc config show broadcast --expanded and lxc config show patriotsplace --expanded?

The LXD 3.0.X LTS release is pretty old now and is not getting bug fixes.
I believe the issue has been fixed in the LXD 4.0.x LTS range.

However as workaround for you, you need to ensure that the instance copy has its own MAC address. To do this you need to remove the volatile.eth0.hwaddr config key from the instance copy using lxc config unset patriotsplace volatile.eth0.hwaddr.

Then try starting it up.

$ lxc config show broadcast --expanded
architecture: x86_64
config:
image.architecture: amd64
image.description: ubuntu 20.04 LTS amd64 (release) (20200423)
image.label: release
image.os: ubuntu
image.release: focal
image.serial: ā€œ20200423ā€
image.version: ā€œ20.04ā€
volatile.base_image: 3ad8264a3075b365ea53ef03292be0a8d727429d30bf38b8631b2df8aea5f1a9
volatile.eth0.hwaddr: 00:16:3e:91:2d:b8
volatile.idmap.base: ā€œ0ā€
volatile.idmap.next: ā€˜[{ā€œIsuidā€:true,ā€œIsgidā€:false,ā€œHostidā€:100000,ā€œNsidā€:0,ā€œMaprangeā€:65536},{ā€œIsuidā€:false,ā€œIsgidā€:true,ā€œHostidā€:100000,ā€œNsidā€:0,ā€œMaprangeā€:65536}]ā€™
volatile.last_state.idmap: ā€˜[{ā€œIsuidā€:true,ā€œIsgidā€:false,ā€œHostidā€:100000,ā€œNsidā€:0,ā€œMaprangeā€:65536},{ā€œIsuidā€:false,ā€œIsgidā€:true,ā€œHostidā€:100000,ā€œNsidā€:0,ā€œMaprangeā€:65536}]ā€™
volatile.last_state.power: RUNNING
devices:
eth0:
ipv4.address: 10.90.200.61
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
ephemeral: false
profiles:

  • default
    stateful: false
    description: ā€œā€

$ lxc config show patriotsplace --expanded
architecture: x86_64
config:
image.architecture: amd64
image.description: ubuntu 20.04 LTS amd64 (release) (20200423)
image.label: release
image.os: ubuntu
image.release: focal
image.serial: ā€œ20200423ā€
image.version: ā€œ20.04ā€
volatile.base_image: 3ad8264a3075b365ea53ef03292be0a8d727429d30bf38b8631b2df8aea5f1a9
volatile.eth0.hwaddr: 00:16:3e:b9:47:ef
volatile.idmap.base: ā€œ0ā€
volatile.idmap.next: ā€˜[{ā€œIsuidā€:true,ā€œIsgidā€:false,ā€œHostidā€:100000,ā€œNsidā€:0,ā€œMaprangeā€:65536},{ā€œIsuidā€:false,ā€œIsgidā€:true,ā€œHostidā€:100000,ā€œNsidā€:0,ā€œMaprangeā€:65536}]ā€™
volatile.last_state.idmap: ā€˜[{ā€œIsuidā€:true,ā€œIsgidā€:false,ā€œHostidā€:100000,ā€œNsidā€:0,ā€œMaprangeā€:65536},{ā€œIsuidā€:false,ā€œIsgidā€:true,ā€œHostidā€:100000,ā€œNsidā€:0,ā€œMaprangeā€:65536}]ā€™
volatile.last_state.power: RUNNING
devices:
eth0:
ipv4.address: 10.90.200.61
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
ephemeral: false
profiles:

  • default
    stateful: false
    description: ā€œā€

Oh, you have a statically assigned IP and havenā€™t updated it in your copy.

ipv4.address: 10.90.200.61

This is ā€œfixedā€ in LXD 4.0 LTS because it would detect the duplicate and refuse to copy.

You need to assign a different IP to the copy using:

lxc config device set patriotsplace eth0 ipv4.address n.n.n.n

Actually the IP is assigned via DHCP within LXD.

And your command lxc config device set patriotsplace eth0 ipv4.address=n.n.n.n
does not work. Error: Invalid number of arguments

Can you try like that, lxc config device override patriotsplace eth0 ipv4.address=n.n.n.n then restart.
Thanks.

I get ā€œError: The device already existsā€

Yes, its using a static DHCP allocation from LXD. Which is set to the same IP for both containers.

Use lxc config device set patriotsplace eth0 ipv4.address n.n.n.n

This is an old version of LXD and doesnā€™t support the = assignment operator.

1 Like

Thanks Thomas. That appears to have fixed it! I donā€™t quite understand how it works because I gave it an IP of 192.168.1.234 in the lxc config command but 192.168.1.166 was assigned?

I appreciate you taking the time for me!!

Ray

1 Like