Docker Cookbook


Using Docker in GCE Google-Container Instances



Download 6,31 Mb.
Pdf ko'rish
bet199/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   195   196   197   198   199   200   201   202   ...   260
Bog'liq
Docker Cookbook

8.9 Using Docker in GCE Google-Container Instances
Problem
You know how to start instances in Google GCE and configure Docker to be set up at
boot time, but you would like to use an image that is already configured with Docker.
Solution
As mentioned in 
Recipe 8.3
, GCE offers 
container-optimized images
.
Make sure that you set your project to the project ID with 
gcloud
config set project
.
$ gcloud compute images list
NAME PROJECT ALIAS DEPRECATED STATUS
...
container-vm-v20141208 google-containers container-vm READY
container-vm-v20150112 google-containers container-vm READY
container-vm-v20150129 google-containers container-vm READY
...
These 
images
, which are based on Debian 7, contain the Docker daemon and the
Kubernetes
kubelet
service.
252 | Chapter 8: Docker in the Cloud


Kubernetes is discussed in more detail in 
Chapter 5
.
The 
kubelet
service running in instances based on these images allows the user to
pass a manifest (known as a 
pod
) that describes the set of containers that need to run
in the instance. The 
kubelet
will start the containers and monitor them. A pod mani‐
fest is a YAML file like so:
version: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- name: nginx
hostPort: 80
containerPort: 80
Your image in the pod manifest can reference an image in the Goo‐
gle Container Registry (see 
Recipe 8.8
)—for instance, 
gcr.io/
/busybox
.
This simple manifest describes a single container based on the 
nginx
image and an
exposed port. You can pass this manifest to the 
gcloud
instance creation command.
Save the preceding YAML file in 
nginx.yml
to start the instance:
$ gcloud compute instances create cookbook-gce \
--image container-vm \
--metadata-from-file google-container-manifest=nginx.yml \
--zone europe-west1-c \
--machine-type f1-micro
In your Google GCE console, you can browse to the started instance (see 
Figure 8-9
).
You can allow HTTP traffic as well as see the container manifest you passed. If the
API version has been updated, you will see a 
v1
instead of a 
v2
. Once the containers
defined in the pod manifest have started, open your browser at the IP of the instance
on port 80 and you will see the Nginx welcome page.

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   195   196   197   198   199   200   201   202   ...   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