Docker Cookbook



Download 6,31 Mb.
Pdf ko'rish
bet172/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   168   169   170   171   172   173   174   175   ...   260
Bog'liq
Docker Cookbook

Docker Hosts
Problem
You want to manage containers in production through a system that supports multi‐
host networking, an overlay network that allows containers to reach each other
without complex port-forwarding rules, group management, and a powerful dash‐
board.
Solution
Consider 
Rancher
 from 
Rancher Labs
, the makers of Rancher OS (see 
Recipe 6.10
). It
is straightforward to set up with a management server running as a container and a
worker agent running as a container as well.
To easily test Rancher and see whether it suits your needs, clone the project reposi‐
tory on 
GitHub
and start a virtual machine locally through Vagrant, as shown here:
$ git clone https://github.com/rancherio/rancher.git
$ cd rancher
$ vagrant up
The virtual machine started is based on CoreOS (see 
Recipe 6.1
), but you could use
any other OS that runs Docker. The Vagrantfile contains two provisioning steps that
install the management server and the worker agent from Docker images. You can
use these commands almost identically to start Rancher on your own machines.
Once in the Rancher dashboard, if you navigate to the Add Host
button, you will be presented with the exact Docker command to
run on another host to join this Rancher deployment.
$ docker run -d -p 8080:8080 rancher/server:latest
$ docker run -e CATTLE_AGENT_IP=172.17.8.100 --privileged -e WAIT=true \
-v /var/run/docker.sock:/var/run/docker.sock \
rancher/agent:latest http://localhost:8080
Once the Vagrant machine is up and the Rancher images have been downloaded, two
containers will start and you will be able to access the Rancher dashboard at 
http://
localhost:8080
.
7.9 Using Rancher to Manage Containers on a Cluster of Docker Hosts | 213


If you already have a server running on port 8080 in your local
machine, Vagrant will pick a different port to serve the Rancher UI
on. You can always access it by using the host-only network at
http://172.17.8.100:8080
.
The dashboard will show only one host and no running containers. By clicking Add
Container, you will be redirected to a page where you can set the container run
parameters (see 
Figure 7-5
). You can expand the 
Advanced Options
area to set param‐
eters such as environment variables, volumes, networking, and capabilities of the
containers (e.g., memory, privileged mode). By default, the networking will be a so-
called managed network, which will use a network overlay. You can still use the
default Docker networking.
Considering the changes that will happen with Docker networking,
this recipe does not expand on the Rancher overlay itself. See
Chapter 3
for more information.
Rancher will build a network overlay, even though in this case you are using a single
host, and start the container within the IP range of the overlay. If you map the
exposed port of the container to a port on the host, you will be able to access it
through your browser. For example, if you start Nginx and map it to port 80 of the
host, you will enjoy the welcome screen of Nginx. The container creation screen looks
like 
Figure 7-6
.

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   168   169   170   171   172   173   174   175   ...   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