Docker Cookbook



Download 6,31 Mb.
Pdf ko'rish
bet109/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   105   106   107   108   109   110   111   112   ...   260
Bog'liq
Docker Cookbook

from
docker.client
import
Client
>>>
from
docker.utils
import
kwargs_from_env
>>>
client
=
Client
(
**
kwargs_from_env
())
>>>
client
.
containers
()
[]
4.11 Using docker-py Securely
Problem
You want to use the 
docker-py
Python client to access a remote Docker daemon set up
with TLS secure access.
Solution
After setting up a Docker host as explained in 
Recipe 4.9
, verify that you can connect
to the Docker daemon with TLS. For example, assuming a host with the hostname
dockerpytls
and client certificate, key, and CA located in the default location at
~/.docker/
, try this:
$ docker -H tcp://dockerpytls:2376 --tlsverify ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4.11 Using docker-py Securely | 125


Make sure you have installed 
docker_py
:
sudo apt-get -y install python-pip
sudo pip install docker-py
Once this is successful, open a Python interactive shell and create a 
docker-py
client
instance by using the following configuration:
tls_config
=
docker
.
tls
.
TLSConfig
(
client_cert
=
(
'/home/vagrant/.docker./cert.pem'
,
\
'/home/vagrant/.docker/key.pem'
),
\
ca_cert
=
'/home/vagrant/.docker/ca.pem'
)
client
=
docker
.
Client
(
base_url
=
'https://host:2376'
,
tls
=
tls_config
)
This is equivalent to calling the Docker daemon on the command line as follows:
$ docker -H tcp://host:2376 --tlsverify --tlscert /path/to/client-cert.pem \
--tlskey /path/to/client-key.pem \
--tlscacert /path/to/ca.pem ...

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   105   106   107   108   109   110   111   112   ...   260




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish