No Network in CentOS 7 Container
The CentOS 7 container from images:centos/7/amd64
doesn’t get a network connection.
The host is Gentoo (using OpenRC for init, and dhcpcd as network manager).
Kernel: 5.4.97
LXD: 4.0.4-r5 (latest available via portage)
I also tried running archlinux/current/amd64
, alpine/3.13/amd64
and centos/8/amd64
: All of them just worked.
Here is what I did to check the connection, both of CentOS 7 (c7) and CentOS 8 (c8):
# lxc exec c7 ping d-mn.org
ping: d-mn.org: Name or service not known
# lxc exec c7 ping 185.26.156.93
connect: Network is unreachable
# lxc exec c8 ping d-mn.org
PING d-mn.org (185.26.156.93) 56(84) bytes of data.
64 bytes from gehrels.uberspace.de (185.26.156.93): icmp_seq=1 ttl=56 time=25.9 ms
…
# lxc exec c7 ip route
# there’s no output by this command
# lxc exec c8 ip route
default via 10.204.58.1 dev eth0 proto dhcp metric 100
10.204.58.0/24 dev eth0 proto kernel scope link src 10.204.58.8 metric 100
Initially launching c7 using lxc launch images:centos/7/amd64 c7
went without any errors.
But the container could not be stopped without -f
: lxc stop -f c7
.
The container did not get an IPV4 address.
# lxc ls
+------+---------+--------------------+-----------------------------------------------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+---------+--------------------+-----------------------------------------------+-----------+-----------+
| c7 | RUNNING | | fd42:c3a4:d8ce:f043:216:3eff:fe6c:846e (eth0) | CONTAINER | 0 |
+------+---------+--------------------+-----------------------------------------------+-----------+-----------+
| c8 | RUNNING | 10.204.58.8 (eth0) | fd42:c3a4:d8ce:f043:216:3eff:fecd:ba31 (eth0) | CONTAINER | 0 |
+------+---------+--------------------+-----------------------------------------------+-----------+-----------+
# lxc info c7 --show-log
Name: c7
Location: none
Remote: unix://
Architecture: x86_64
Created: 2021/02/13 11:11 UTC
Status: Running
Type: container
Profiles: default
Pid: 13934
Ips:
eth0: inet6 fd42:c3a4:d8ce:f043:216:3eff:fe6c:846e veth737a0cf6
eth0: inet6 fe80::216:3eff:fe6c:846e veth737a0cf6
lo: inet 127.0.0.1
lo: inet6 ::1
Resources:
Processes: 1
Network usage:
eth0:
Bytes received: 65.35kB
Bytes sent: 966B
Packets received: 248
Packets sent: 11
lo:
Bytes received: 2.12kB
Bytes sent: 2.12kB
Packets received: 26
Packets sent: 26
Log:
# lxc config show c7
architecture: x86_64
config:
image.architecture: amd64
image.description: Centos 7 amd64 (20210213_07:08)
image.os: Centos
image.release: "7"
image.serial: "20210213_07:08"
image.type: squashfs
volatile.base_image: 8b8c8b9b93a740aea97c90163f10e4d0dedc4f56ad085651e1a9d6afb5c36b0b
volatile.eth0.host_name: veth737a0cf6
volatile.eth0.hwaddr: 00:16:3e:6c:84:6e
volatile.idmap.base: "0"
volatile.idmap.current: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
volatile.last_state.power: RUNNING
devices: {}
ephemeral: false
profiles:
- default
stateful: false
description: ""
There is only one profile (default).
# lxc profile show default
config: {}
description: Default LXD profile
devices:
eth0:
name: eth0
network: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
name: default
used_by:
- /1.0/instances/c7
- /1.0/instances/c8
I hope I included all necessary information to help figure this out. I am grateful for any little hint. Thank you!