Docker Cookbook


| Chapter 8: Docker in the Cloud



Download 6,31 Mb.
Pdf ko'rish
bet194/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   190   191   192   193   194   195   196   197   ...   260
Bog'liq
Docker Cookbook

244 | Chapter 8: Docker in the Cloud


$ docker-machine create -h
...
OPTIONS:
--amazonec2-access-key AWS Access Key [$AWS_ACCESS_KEY_ID]
--amazonec2-ami AWS machine image [$AWS_AMI]
--amazonec2-instance-type 't2.micro' AWS instance type [$AWS_INSTANCE_TYPE]
--amazonec2-region 'us-east-1' AWS region [$AWS_DEFAULT_REGION]
--amazonec2-root-size '16' AWS root disk size (in GB) ...
--amazonec2-secret-key AWS Secret Key [$AWS_SECRET_ACCESS_KEY]
--amazonec2-security-group AWS VPC security group ...
--amazonec2-session-token AWS Session Token [$AWS_SESSION_TOKEN]
--amazonec2-subnet-id AWS VPC subnet id [$AWS_SUBNET_ID]
--amazonec2-vpc-id AWS VPC id [$AWS_VPC_ID]
--amazonec2-zone 'a' AWS zone for instance ... [$AWS_ZONE]
Finally, 
machine
will create an SSH key pair and a security group for you. The security
group will open traffic on port 2376 to allow communications over TLS from a
Docker client. 
Figure 8-6
shows the rules of the security group in the AWS console.
Figure 8-6. Security group for machine
8.6 Starting a Docker Host on Azure with Docker Machine
Problem
You know how to start a Docker host on Azure by using the Azure CLI, but you
would like to unify the way you start Docker hosts in multiple public clouds by using
Docker Machine.
8.6 Starting a Docker Host on Azure with Docker Machine | 245


Solution
Use the Docker Machine Azure driver. In 
Figure 1-7
, you saw how to use 
Docker
Machine
to start a Docker host on DigitalOcean. The same thing can be done on
Microsoft Azure. You will need a valid subscription to 
Azure
.
You need to download the 
docker-machine
binary. Go to the documentation 
site
 and
choose the correct binary for your local computer architecture. For example,
on OS X:
$ wget https://github.com/docker/machine/releases/download/v0.4.0/ \
docker-machine_darwin-amd64
$ mv docker-machine_darwin-amd64 docker-machine
$ chmod +x docker-machine
$ ./docker-machine --version
docker-machine version 0.3.0
With a valid Azure subscription, create an X.509 certificate and upload it through the
Azure 
portal
. You can create the certificate with the following commands:
$ openssl req -x509 -nodes -days 365 -newkey rsa:1024 \
-keyout mycert.pem -out mycert.pem
$ openssl pkcs12 -export -out mycert.pfx -in mycert.pem -name "My Certificate"
$ openssl x509 -inform pem -in mycert.pem -outform der -out mycert.cer
Upload 
mycert.cer
and define the following environment variables:
$ export AZURE_SUBSCRIPTION_ID=
$ export AZURE_SUBSCRIPTION_CERT=mycert.pem
You can then use 
docker-machine
and set your local Docker client to use this remote
Docker daemon:
$ ./docker-machine create -d azure goasguen-foobar
INFO[0002] Creating Azure machine...
INFO[0061] Waiting for SSH...
INFO[0360] "goasguen-foobar" has been created and is now the active machine.
INFO[0360] To point your Docker client at it, run this in your shell: \
$(docker-machine env goasguen-foobar)
$ ./docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
toto1111 * azure Running tcp://goasguen-foobar.cloudapp.net:2376
$ $(docker-machine env goasguen-foobar)
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
In this example, 
goasguen-foobar
is the name that I gave to my
Docker machine. This needs to be a globally unique name. Chances
are that names like 
foobar
and 
test
have already been taken.

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   190   191   192   193   194   195   196   197   ...   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