Docker Cookbook


| Chapter 8: Docker in the Cloud



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

246 | Chapter 8: Docker in the Cloud


Discussion
With your local Docker client set up to use the remote Docker daemon running in
this Azure virtual machine, you can pull images from your favorite registries and
start containers.
For example, let’s start an Nginx container:
$ docker pull nginx
$ docker run -d -p 80:80 nginx
To expose port 80 of this remote host in Azure, you need to add an endpoint to the
VM that was created. Head over to the Azure portal, select the VM (here, 
goasguen-
foobar
), and add an endpoint for the HTTP request, as in 
Figure 8-7
. Once the end‐
point is created, you can access Nginx at 
http://.cloudapp.net
.
Figure 8-7. Azure endpoint for a virtual machine
See Also
• Docker Machine Azure driver 
documentation
8.7 Running a Cloud Provider CLI in a Docker Container
Problem
You want to take advantage of containers and run your cloud provider CLI of choice
within a container. This gives you more portability options and avoids having to
install the CLI from scratch. You just need to download a container image from the
Docker Hub.
8.7 Running a Cloud Provider CLI in a Docker Container | 247


Solution
For the Google GCE CLI, there is a public 
image
 maintained by Google. Download
the image via 
docker pull
and run your GCE commands through interactive
ephemeral containers.
For example, using 
boot2docker
on an OS X machine:
$ boot2docker up
$ $(boot2docker shellinit)
$ docker pull google/cloud-sdk
$ docker images | grep google
google/cloud-sdk latest a7e7bcdfdc16 10 days ago 1.263 GB
You can then log in and issue commands as described in 
Recipe 8.3
. The only differ‐
ence is that the CLI is running within containers. The login command is issued
through a named container. That named container is used as a data volume container
(i.e., 
--volumes-from cloud-config
) in subsequent CLI calls. This allows you to use
the authorization token that is stored in it:
$ docker run -t -i --name gcloud-config google/cloud-sdk gcloud auth login
Go to the following link in your browser:
...
$ docker run --rm \
-ti \
--volumes-from gcloud-config google/cloud-sdk \
gcloud compute zones list
NAME REGION STATUS NEXT_MAINTENANCE TURNDOWN_DATE
asia-east1-c asia-east1 UP
asia-east1-a asia-east1 UP
asia-east1-b asia-east1 UP
europe-west1-b europe-west1 UP
europe-west1-c europe-west1 UP
us-central1-f us-central1 UP
us-central1-b us-central1 UP
us-central1-a us-central1 UP
Using an alias makes things even better:
$ alias magic='docker run --rm \
-ti \
--volumes-from gcloud-config \
google/cloud-sdk gcloud'
$ magic compute zones list
NAME REGION STATUS NEXT_MAINTENANCE TURNDOWN_DATE
asia-east1-c asia-east1 UP
asia-east1-a asia-east1 UP
asia-east1-b asia-east1 UP
europe-west1-b europe-west1 UP
europe-west1-c europe-west1 UP
us-central1-f us-central1 UP

Download 6,31 Mb.

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