4

I am trying to create CentOS container inside CentOS 7 and host my application. But I am unable to install anything inside container.

If I do 'yum -y install nodejs' i got below error

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.fibergrid.in
 * extras: mirror.fibergrid.in
 * updates: mirror.fibergrid.in
No package nodejs available.
Error: Nothing to do

It is found that internet is not available inside the container, but outside the container internet is available.

4
  • Nodejs isnt something you can easily install using "yum -y install nodejs" please check: serverfault.com/questions/299288/… digitalocean.com/community/tutorials/…
    – Dylan_R
    Commented Mar 2, 2017 at 9:23
  • I am not able to get internet inside container
    – sudheer KB
    Commented Mar 2, 2017 at 10:43
  • yum install wget Loaded plugins: fastestmirror Could not retrieve mirrorlist mirrorlist.centos.org/… error was 14: curl#7 - "Failed to connect to 2607:f8f8:700:12::10: Network is unreachable"
    – sudheer KB
    Commented Mar 2, 2017 at 10:44
  • Please comment on how the solutions from these two posts work (or not) for you: article1 and article2. If they don't work, please add to your post the same information as provided by the posters of these posts.
    – harrymc
    Commented Mar 6, 2017 at 9:46

3 Answers 3

3
+50

I would reword your question I am not able to get internet inside container and look into similar ones.

Some suggestions you might try are:

service docker restart

and

pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
docker -d

UPDATE: Since you later specified you are using lxc, I'd search for "no internet connection inside lxc containers". For another user (who posted his config in greater detailed, see here) it was a firewall issue. He had to add:

-A FORWARD -s 10.0.3.0/24 -o eth0 -j ACCEPT                                     
-A FORWARD -d 10.0.3.0/24 -o lxcbr0 -j ACCEPT

UPDATE: I setup a CentOS 7 system just to test this, and was able to create a CentOS lxc container inside it effortlessly following these instructions. It has external connectivity without any need to tweak the config.

yum install epel-release
yum install debootstrap perl libvirt
yum install lxc lxc-templates
systemctl start lxc.service
systemctl start libvirtd 
lxc-create -n <name> -t centos
lxc-start -n <name>
yum install epel-release
yum -y install nodejs

Here is the resulting network config inside the container:

ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
      valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
      valid_lft forever preferred_lft forever
5: eth0@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether fe:9d:63:f7:72:ec brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.122.153/24 brd 192.168.122.255 scope global dynamic eth0
      valid_lft 3437sec preferred_lft 3437sec
    inet6 fe80::fc9d:63ff:fef7:72ec/64 scope link
      valid_lft forever preferred_lft forever

cat /etc/resolv.conf
; generated by /usr/sbin/dhclient-script
nameserver 192.168.122.1

 ip route
 default via 192.168.122.1 dev eth0
 169.254.0.0/16 dev eth0  scope link  metric 1005
 192.168.122.0/24 dev eth0  proto kernel  scope link  src 192.168.122.153

 iptables -L
 Chain INPUT (policy ACCEPT)
 target     prot opt source               destination
 Chain FORWARD (policy ACCEPT)
 target     prot opt source               destination
 Chain OUTPUT (policy ACCEPT)
 target     prot opt source               destination

If your lxc container is different from mine, please point out the differences; otherwise, the problem more likely lies in the host machine configuration. To know whether it's the firewall I would allow all traffic (temporarily relying on an external firewall) and check again. Also, make sure you have the forwarding rules mentioned earlier. On my CentOS host I found the following IPTABLES entries that were automatically created:

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  0.0.0.0/0            192.168.122.0/24     ctstate RELATED,ESTABLISHED
ACCEPT     all  --  192.168.122.0/24     0.0.0.0/0
3
  • I am not using docker, am using lxc
    – sudheer KB
    Commented Mar 6, 2017 at 9:04
  • Please add that info in your question. Docker uses lxc anyway, so have you tried restarting lxc, the host, recreating the virtual interfaces? Please post the results of your efforts.
    – simlev
    Commented Mar 6, 2017 at 9:10
  • added the same .
    – sudheer KB
    Commented Mar 6, 2017 at 10:11
0
  • First check IP connectivity

Try ping home interface IP shown by ifconfig command. Check default gateway ip from ip route command output IP next to 0.0.0.0 route. Try ping that.

  • If pings are ok, then check DNS configuration:

Run command:

#vi /etc/reslov/conf

nameserver:8.8.8.8
nameserver:8.8.4.4

Set nameserver to host interface IP or local router DNS server address.

  • Restart virtual machine network interface

/etc/init.d/network restart

0

Check your internet connection and enabled the EPEL repository, if not enable:
https://support.rackspace.com/how-to/install-epel-and-additional-repositories-on-centos-and-red-hat/

Then:

$ sudo yum install npm  
$ node -v    

or Can also follow this documents:
http://lexsheehan.blogspot.in/2013/03/how-to-install-nodejs-on-centos.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .