DOCKER - Changing the IP range for docker0 with internet connection.

First, stop docker:
# service docker stop
Redirecting to /bin/systemctl stop  docker.service


Next, create the network bridge file. You can choose any IP range you like. On Oracle linux 7.0 , it looks like this:



# cat /etc/sysconfig/network-scripts/ifcfg-docker0 
DEVICE="docker0"
TYPE=Bridge
ONBOOT="yes"
BOOTPROTO=static
IPADDR=192.168.178.240
NETMASK=255.255.255.0
DNS1=8.8.8.8
GATEWAY=192.168.178.1

The next step is to add a script file to establish the bridge for the physical network device. In this example the device is enp4s0 so we need to create a file name ifcfg-enp4s0  and add the following lines to it. For the purposes of this example we will name the interface docker0:

DEVICE=enp4s0
BRIDGE=docker0
ONBOOT=yes

Restart your network services. 

# service network restart

# service docker restart.

#ip  a  s  docker0

7: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 ...
    link/ether fe:54:00:18:1a:fd brd ff:ff:ff:ff:ff:ff
    inet 192.168.178.240/24 brd 10.100.72.255 scope global docker0


# service docker start
Redirecting to /bin/systemctl start  docker.service

# docker run -i -t centos:latest /bin/bash





Comentarios

Publicar un comentario