Python calls Docker API (CentOS6.5)

Source: Internet
Author: User
Tags install openssl

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
    • #pip Install 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
    • #获取最新更新的 Docker version #wget Http://get.docker.io/builds/Linux/x86_64/docker-latest-O Docker or: wget https:// Get.docker.com/builds/linux/x86_64/docker-latest-o Docker
    • Execute permissions for Docker   chmod +x Docker
    • Use the-D mode to open and disconnect the Docker process and run the Process usage parameters (&) in the background. Make sure you use the./docker version is the latest version of the path instead of the previous version of the path # perform a new version #./docker-d &
      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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.