Configuration and use of docker-py

Source: Internet
Author: User

Test environment

75 machine: Red Hat Enterprise Linux Server 7.0, no extranet access

73 machine: Red Hat Enterprise Linux Server 7.0, no extranet access, Docker Server installed

183 machine: OS X Yosemite 10.10.4, full extranet access, for downloading installation packages

Configuration process

1. If the development environment is networked, install it directly with the following command:

sudo Install docker-py

If you do not have the PIP command installed, you can install it by using the following command:

sudo easy_install pip

2. If the extranet is not available, you will need to download the zip package docker-py-master.zip from GitHub's docker-py page for offline installation. After the download, the ZIP package from the 183-machine SCP to the 75 machine:

SCP docker-py-master. Zip [Email protected] 10.11. 150.75:/opt/scs/openxxs/

Unzip on the 75 machine:

Unzip Docker-py-master. Zip

View the setup.py file and discover that there are three dependent packages that need to be installed and have version requirements:

requirements = [    'requests >= 2.5.2',    'Six >= 1.3.0',    'websocket-client >= 0.32.0' ,]

You can download requests, six, and websocket-client three installation packages from the following Web site (if you do not know the URL, you will be prompted to run sudo python setup.py install):

Requests:https://pypi.python.org/simple/requests/Six:https://pypi.python.org/ simple/six/Websocket-client:https://pypi.python.org/simple/websocket-client/

After the completion of the download SCP to 75 machine and then use TAR-ZXVF decompression, according to the following sequence installation:

CD requests-2.7. 0 sudo Install CD.. /six-1.9. 0 sudo Install CD.. /websocket_client-0.32. 0 sudo Install CD.. /docker-py-mastersudoinstall

3. Install the docker-py in the same way on the 73 machine

4. Start the Docker server on a 73 machine with a UNIX socket:

[@tc_150_73 ~]$sudoDocker-d &[1]1255[@tc_150_73~]$ info[0000] Listening forHTTP on Unix (/var/run/docker.sock) info[0000] [Graphdriver] using prior storage driver"Devicemapper"warn[0000] RunningmodprobeBridge Nf_nat failed with message:, Error:exit status1info[0000] Loading Containers:start. .. info[0000] Loading containers: Done. info[0000] Daemon has completed initialization info[0000] Docker Daemon commit=0baf609 execdriver=native-0.2Graphdriver=devicemapper version=1.7.0

After opening several Docker containers on the 73 machine, test the following:

[@tc_150_73 ~]$ Pythonpython2.7.5(Default, APR9  -, One:Geneva: +) [GCC4.8.3 20140911(Red Hat4.8.3-9)] on Linux2type" Help","Copyright","credits"Or"License"  for  Moreinformation.>>>From Docker import Client>>> CLT = Client (base_url='Unix://var/run/docker.sock')>>>clt.containers () [{u'Status': U'Up about a minute', u'Created':1437743168, u'Image': U'centos:7', u'Labels': {}, U'Ports': [], U'Command': U'/bin/bash', u'Names': [u'/suspicious_galileo'], U'Id': U'a81dbf9200fbf6a4180e8b8e80f4fe30b3f8be612ea0e58ac04fb65080429043'}]>>>

You can see that the running container is displayed normally, and the Unix socket method is tested successfully.

5. Close the Docker server that was just opened on the 73 machine (using service Docker stop and Systemctl Docker stop is not valid):

sudo Killall Docker

6. Start the Docker server on a 73-machine TCP mode:

[@tc_150_73 ~]$sudoDocker-h0.0.0.0:2375-D &[1]1625[@tc_150_73~]$ warn[0000]/!\ DON'T BIND on any IP ADDRESS without setting-tlsverify IF you DON'T KNOW What do you'RE DOING/!\info[0000] Listening forHTTP on TCP (0.0.0.0:2375) info[0000] [Graphdriver] using prior storage driver"Devicemapper"warn[0000] RunningmodprobeBridge Nf_nat failed with message:, Error:exit status1info[0000] Loading Containers:start. .... info[0000] Loading containers: Done. info[0000] Daemon has completed initialization info[0000] Docker Daemon commit=0baf609 execdriver=native-0.2Graphdriver=devicemapper version=1.7.0

On the 75 machine, the test results are as follows:

[@tc_150_75 ~]$ Pythonpython2.7.5(Default, APR9  -, One:Geneva: +) [GCC4.8.3 20140911(Red Hat4.8.3-9)] on Linux2type" Help","Copyright","credits"Or"License"  for  Moreinformation.>>>From Docker import Client>>> CLT = Client (base_url='tcp://10.11.150.73:30001')>>>clt.containers () []

The TCP mode test succeeds (this shows the state of the running container on the 73 machine , not, so it is empty).

Related installation package Baidu cloud Backup
http://Pan.baidu.com/s/1sjmi8oh

Configuration and use of docker-py

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.