Skip to content

Commit cd36b92

Browse files
authored
Create DockerNetworking
1 parent 8c458a3 commit cd36b92

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Docker/DockerNetworking

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
To set custome IP address range to your container in docker
2+
3+
sudo vim /etc/default/docker
4+
add this line to file
5+
6+
DOCKER_OPTS="--bip=10.66.33.10/24"
7+
then reboot
8+
after reboot start a container
9+
10+
docker run -it --name t2 jangorecki/r-base-dev /bin/bash
11+
and check ip of a container
12+
13+
docker inspect --format '{{ .NetworkSettings.IPAddress }}' t2
14+
15+
16+
OR
17+
18+
docker exec -it c1 bash -c "echo -e 'IPADDR=172.17.0.4 \n HOSTNAME=c1' >> /etc/sysconfig/network-scripts/ifcfg-eth0; /etc/init.d/network restart";
19+
20+
21+
OR - to change the IP address of this docker container
22+
23+
You will have to first detach the container from the custom network and the connect it back by providing the ip.
24+
25+
You can follow the following steps :
26+
27+
docker network disconnect [OPTIONS] NETWORK CONTAINER
28+
docker network connect --ip 192.168.150.3 NETWORK CONTAINER

0 commit comments

Comments
 (0)