As an operation or test, you can not understand the various kinds of open source tools released every day, but it is better to know about Docker, because this thing will change the micro and macro structure of software in the future. In the era of virtualization in the ascendant, and ushered in the Docker such a thing, continue to split the traditional software architecture, multi-process to play tired, play multi-container?
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5A/05/wKioL1T0GvKyUuKdAAJrHE8Do_0258.jpg "title=" Docker . JPG "alt=" Wkiol1t0gvkyuukdaajrhe8do_0258.jpg "/>
Based on a few days of superficial testing, found a few interesting features:
1, isolation level of the problem. For application Container, you can see that the isolation level must be less than the virtual machine. However, although it appears that the 1th process of the Docker container is completely different from the host, it still has a connection to the host, such as launching an Apache in the Docker container and discovering that there are 3 Apache processes on the host, and that it is a completely different process number.
2, the issue of starting multiple services. Some people on the internet said that the service to be launched into a script, and then copy the script to the image, and then start with a cmd, I have not been successful trial. Finally, it's supervisord, and it's no problem trying to pull a lot of services. Note that there is no supervisord in the basic source of centos6.5, you must first install Epel
3, IP address problem. When running a Docker container, such as:
# docker run--name=mysql_contain1-h=mysql_host1-d-P docker_mysql
You can set the container name, you can set the container host name, but it seems to be unable to set the IP address?
Host has a DOCKER0 virtual network card, the address is 192.168.42.1, found the new Docker container IP address and then continue to accumulate.
4. If we have a MySQL image, is it possible to dynamically boot the container to get the load over, based on the host load threshold? Did a small experiment, when the host's MySQL connection number more than 500, start a MySQL container, the code is meaningless, purely testing:
#!/usr/bin/python
# Filename:db3.py
# description:a demo to access MySQL based on dynamic Docker containers
# Python 2.7.6
Import MySQLdb
Import commands
Import OS
Import Random
Import time
Image_name= ' Docker_mysql '
master_host_ip= ' 127.0.0.1 '
Prefix_cont= ' Mysql_cont '
num_thread=500
Def getdockerip ():
I=random.randint (1,10000)
Shell= ' Mysqladmin-uroot-proot status|awk \ ' {print $4}\ '
Try
thread = Int (commands.getoutput (shell))
Except Exception:
print ' Get thread number of Master SQL error '
Exit (1)
if (Thread > Num_thread):
str=prefix_cont+ '%d '%i
os.environ[' Cont_name ']=str
os.environ[' Image_name ']=image_name
Ret=os.system (' Docker run--name= ' $cont _name "-d-p $image _name >docker.log 2>&1 ')
if (ret <> 0):
print ' Create docker for MySQL error '
Exit (2)
Shell2= ' Docker inspect ' $cont _name "|grep ipaddress|grep-eo \ ' [0-9]{1,3}\. [0-9] {1,3}\. [0-9] {1,3}\. [0-9] {1,3}\ '
Str_ip=commands.getoutput (SHELL2)
Return STR_IP
Return MASTER_HOST_IP
def insertdata (v):
Des_host_ip=getdockerip ()
Print Des_host_ip
print ' begin to insert data to ' +DES_HOST_IP
Time.sleep (3)
Try
My_conn=mysqldb.connect (Host=des_host_ip,port = 3306,user= ' root ', passwd= ' root ', db = ' db_test ')
cur = my_conn.cursor ()
Sql= "INSERT into T (ID) VALUES ('%d ')"% (v)
Cur.execute (SQL)
Cur.close ()
My_conn.commit ()
My_conn.close ()
print ' Insert data to ' +des_host_ip+ ' successfully! '
Except Mysqldb.error,e:
Print "Mysql Error%d:%s"% (E.args[0], e.args[1])
Exit (3)
InsertData (2015)
adjourned
This article is from the "writing is a good habit" blog, please be sure to keep this source http://weikle.blog.51cto.com/3324327/1616561
Docker, a long time will be together, a long time must be divided?