Docker Cookbook


| Chapter 1: Getting Started with Docker



Download 6,31 Mb.
Pdf ko'rish
bet31/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   27   28   29   30   31   32   33   34   ...   260
Bog'liq
Docker Cookbook

26 | Chapter 1: Getting Started with Docker


RUN (/usr/bin/mysqld_safe &); sleep 5; mysqladmin -u root -proot create wordpress
COPY wp-config.php /var/www/html/wp-config.php
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 80
CMD ["/usr/bin/supervisord"]
Supervisor is configured via the 
supervisord.conf
file like so:
[supervisord]
nodaemon=true
[program:mysqld]
command=/usr/bin/mysqld_safe
autostart=true
autorestart=true
user=root
[program:httpd]
command=/bin/bash -c "rm -rf /run/httpd/* && /usr/sbin/apachectl -D FOREGROUND"
Two programs are defined to be run and monitored: 
mysqld
and 
httpd
. Each pro‐
gram can use various options like 
autorestart
and 
autostart
. The most important
directive is 
command
, which defines how to run each program. With this configura‐
tion, a Docker container needs to run only a single foreground process: 
supervisord
.
Hence the line in the Dockerfile, 
CMD ["/usr/bin/supervisord"]
.
On your Docker host, build the image and start a background container off of it. If
you are using the Vagrant virtual machine started via the example files, do this:
$ cd /vagrant
$ docker build -t wordpress .
$ docker run -d -p 80:80 wordpress
Port forwarding will be set up between your host and the Docker container for port
80. You will just need to open your browser to 
">http://
and
configure WordPress.
Discussion
Although using Supervisor to run multiple application services in a single container
works perfectly, it is better to use multiple containers. It promotes the isolation of
concerns using containers and helps create a microservices-based design for your
application (see 
Building Microservices
). Ultimately, this will help with scale and resil‐
iency.

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   27   28   29   30   31   32   33   34   ...   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