An environmental background
- python-2.7.8
- Docker version 1.15 (*yum installed as 1.14, upgrade to 1.15, see next steps)
Two Get Docker container indicator "indicator feasibility analysis See note:"
- CPU:USR and System Cpu time
- Memory
- ip
Three overall steps
- Container Indicator Value Acquisition
- Docker Python API Environment setup
- Get Indicator Feasibility analysis
Four specific implementations 1 the following Python script to get the specified container ID of the IP,CPU, and memory "* Block Diagram section to introduce the Python Docker API" 2:python Docke API Installation When the API is not installed, running Python will error: No model named Docker installation steps are as follows:
A: Download Setuptools
- # wget https://pypi.python.org/packages/source/s/setuptools/setuptools-3.3.tar.gz
- # python setup.py Build
- # python setup.py Install
-
- PS: If you encounter the following error:
- Yum Install zlib
- Yum Install Zlib-devel
- After the installation is complete, recompile python2.7 "Do not need to delete, only need to recompile, make, install on the line" # cd/usr/local/python-2.7.8 # make Clean # made # make install
B install pip
- # wget--no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
- #tar ZVXF 1.5.5.tar.gz
- #cd pip-1.5.5/
- #python setup.py Install "* fromsetuptools import Setup,importerror:no module named Setuptools, solve such as a"
C Installation Docker-py
Error:
Resolved as follows: Yum installs OpenSSL and Openssl-devel. Then recompile python.
# yum Install OpenSSL
# yum Install-devel
D Upgrade Docker version (1.14) to 1.15
- Kill Docker running Process #killall Docker
Or you can replace the docker[under/usr/local/bin to change the original Docker to dockertemp storage for insurance purposes, but not delete it.
- Finally restart the docker:# service Docker restart
PS: If you do not upgrade Docker, you will encounter the following error:
E Run a python script
# python testcpu.py
Reference: 0 http://docs.docker.com/reference/api/docker-io_api/"Official information" 1 http://masato.github.io/2014/11/16/ salt-docker-pulled-api-error/#more "Client Server version different" 2 http://www.2cto.com/os/201309/246571.html "Linux Salt Installation" 3 Http://xiaorui.cc/2014/08/13/%E5%88%A9%E7%94%A8python%E7%9A%84docker-py%E8%BF%9B%E8%A1%8Cdocker%E7%9A%84api%E6 %93%8D%E4%BD%9C/4 https://code.csdn.net/u010702509/docker_upgrading http://blog.csdn.net/limingjian/article/ details/40298217 "Update Docker"
Python calls Docker API (CentOS6.5)