-
Notifications
You must be signed in to change notification settings - Fork 27
massive container creation with iteration
When we need to create several container, it can be tedious to manually name each OvS port, to define each ip, each OpenFlow port number, each mac address, fortunately you can write a template with $$ placeholder pattern and iterate.
In this example, we want to launch 8 containers ALP4 to ALP11 from alpine docker image and connect them to br0 bridge with following network parameters:
Container | Port | Mac eth0 | ip eth0 | ofport | vlan | gateway |
---|---|---|---|---|---|---|
ALP04 | P04 | aa:00:00:00:00:04 | 192.168.100.4 | 1004 | 100 | 192.168.0.254 |
ALP05 | P05 | aa:00:00:00:00:05 | 192.168.100.5 | 1005 | 100 | 192.168.0.254 |
ALP06 | P06 | aa:00:00:00:00:06 | 192.168.100.6 | 1006 | 100 | 192.168.0.254 |
ALP07 | P07 | aa:00:00:00:00:07 | 192.168.100.7 | 1007 | 100 | 192.168.0.254 |
ALP08 | P08 | aa:00:00:00:00:08 | 192.168.100.8 | 1008 | 100 | 192.168.0.254 |
ALP09 | P09 | aa:00:00:00:00:09 | 192.168.100.9 | 1009 | 100 | 192.168.0.254 |
ALP10 | P10 | aa:00:00:00:00:10 | 192.168.100.10 | 1010 | 100 | 192.168.0.254 |
ALP11 | P11 | aa:00:00:00:00:11 | 192.168.100.11 | 1011 | 100 | 192.168.0.254 |
( With iteration method, you can create a maximum of 99 docker containers in one single button click. )
As in previous chapter, create an interface, a net associated with this interface and a default route; however write $$ placeholder anywhere where you want iteration process to take place. We want to iterate on
- a Container name
- b OvS port name
- c mac address
- d openflow port number
- e ip address
- f press to iterate container creation, a popup will appear:
- f1 Select iteration mode "$$ anywhere"
- f2 Enter 04
- f3 Enter 11
- f4 Validate
You should now see 8 running containers in Docker table, named ALP04, ALP05,...ALP11.
Currently their are running without any network because of --net none
docker option.
We'll see in section 11.4.3 how to iterate networking setup.
- g Press and docker net iteration popup will appear. Fields should already be pre-filled with same values as docker container creation iteration.
Please note that is for container network setup iteration whereas is for container creation iteration!!!
- g1 iteration mode "$$ anywhere"
- g2 04
- g3 11
- g4 Validate
- h0 Go to Port tab
- h1 You should see 8 ports P04 to P11 in port list.
- h2 and h4 note that each port as the required openflow number ( 1004, 1005, etc... )
Let's connect to ALP07 container via a terminal.
- k docker container attach ALP07
- l Let's list interfaces address information
- m We see that our interface is called eth0 as requested.
- n eth0 has requested mac adress aa:00:00:00:00:07
- o eth0 has requested ip address 192.168.100.7
- p ALP07 container can ping ALP09 ( 192.168.100.9 )
- q default route is correct
That's perfect !
© 2018 Nicolas Bonnand, licensed under the Apache License, Version 2.0