Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] lxc-container nginx net dependency
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
mimosinnet
l33t
l33t


Joined: 10 Aug 2006
Posts: 713
Location: Barcelona, Spain

PostPosted: Mon May 07, 2018 7:22 am    Post subject: [solved] lxc-container nginx net dependency Reply with quote

LXC container shows an ethernet device:
Code:
# ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.101  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::4c1f:85ff:fe41:b4c6  prefixlen 64  scopeid 0x20<link>
        ether 4e:1f:85:41:b4:c6  txqueuelen 1000  (Ethernet)
        RX packets 927855  bytes 619875039 (591.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 924704  bytes 62321627 (59.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


OpenRC nginx service fails to start in LXC container:
Code:
# /etc/init.d/nginx start
 * Caching service dependencies ...                                                                                                                                                     [ ok ]
 * Bringing up interface eno1
 *   ERROR: interface eno1 does not exist
 *   Ensure that you have loaded the correct kernel module for your hardware
 * ERROR: net.eno1 failed to start
 * ERROR: cannot start nginx as net.eno1 would not start


Uncommenting the 'net' dependency in /etc/init.d/nginx...
Quote:
depend() {
# need net
use dns logger netmount
}


... solves the issue:
Code:
# /etc/init.d/nginx start
 * Caching service dependencies ...                                                                                                                                                     [ ok ]
 * Checking nginx' configuration ...                                                                                                                                                    [ ok ]
 * Starting nginx ... 


Writing this post made me realise that there may be something wrong with the configuration of the lxc-container. I guess nginx should start without any issue.

Cheers!
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved.
Take care of the community answering unanswered posts.


Last edited by mimosinnet on Fri May 11, 2018 6:52 am; edited 1 time in total
Back to top
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 806

PostPosted: Mon May 07, 2018 8:01 am    Post subject: Reply with quote

I'm running some containers on a server here, including one running nginx. I think the problem is not nginx, but netifrc's way of checking the interface existence. It uses sysfs for that, and usually sysfs is not mounted in lxc's because it exposes information from the host. If you mount sysfs, you'll see the /etc/init.d/net.* scripts work as expected.
In most lxc's the network is already configured in the lxc configuration, so settiing config_eno1="null" in /etc/conf.d/net should be enough to get the dependency satisfied.

In my opinion it would be nice if netifrc could have a backup method to check interfaces in case sysfs is not mounted, /proc/net/dev is the first one i can think of.
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Back to top
View user's profile Send private message
mimosinnet
l33t
l33t


Joined: 10 Aug 2006
Posts: 713
Location: Barcelona, Spain

PostPosted: Wed May 09, 2018 12:00 am    Post subject: Reply with quote

pa4wdh wrote:
I think the problem is not nginx, but netifrc's way of checking the interface existence. It uses sysfs for that, and usually sysfs is not mounted in lxc's because it exposes information from the host. If you mount sysfs, you'll see the /etc/init.d/net.* scripts work as expected.


You diagnostic is right: nginx starts correctly after adding this line to the lxc configuration:

Code:
lxc.mount.entry=sysfs /var/lib/lxc/moodle2018/rootfs/sys sysfs defaults 0 0


The solution is perfect. Removing the previous entry and setting the network interface in the lxc-container as:

Quote:
config_eno1="null"


Allows nginx service to start inside the container.

Thanks!
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved.
Take care of the community answering unanswered posts.
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Wed May 09, 2018 12:45 am    Post subject: Reply with quote

Did you guys tried to just disable it ?
I mean
Code:
/etc/conf.d/nginx
rc_depend="!net"

or in /etc/rc.conf
Code:
rc_nginx_depend="!net"


That should do the same as commenting out the "need net", but without hacking the ebuild each time it gets update.
Back to top
View user's profile Send private message
mimosinnet
l33t
l33t


Joined: 10 Aug 2006
Posts: 713
Location: Barcelona, Spain

PostPosted: Fri May 11, 2018 6:45 am    Post subject: Reply with quote

krinn wrote:
Code:
/etc/conf.d/nginx
rc_depend="!net"


Thanks for the hint! The above setting in the lxc-container works with nginx. Nevertheless, I get the same error with postgresql:

Code:
# /etc/init.d/postgresql-10 start
 * Bringing up interface eth0
 *   config_eth0 not specified; defaulting to DHCP
 *   dhcp ...
 *     Running udhcpc ...
udhcpc: started, v1.28.0
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending discover
udhcpc: no lease, failing
 *     start-stop-daemon: failed to start `/bin/busybox'                                                                                                                                [ !! ]
 * ERROR: net.eth0 failed to start
 * /run/postgresql: creating directory
 * /run/postgresql: correcting owner
 * Starting PostgreSQL 10 ...


Setting 'config_eth0="null"' in the container's '/etc/conf.d/net' works for nginx and postgresql.

Cheers!
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved.
Take care of the community answering unanswered posts.
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Fri May 11, 2018 1:11 pm    Post subject: Reply with quote

of course, that was to point out openrc flexibility.
your solution works, as long as eth0 will keep that name :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum