Docker Cookbook


| Chapter 1: Getting Started with Docker



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

24 | Chapter 1: Getting Started with Docker


latest: Pulling from library/busybox
cf2616975b4a: Pull complete
6ce2e90b0bc7: Pull complete
8c2e06607696: Pull complete
Digest: sha256:df9e13f36d2d5b30c16bfbf2a6110c45ebed0bfa1ea42d357651bc6c736d5322
Status: Downloaded newer image for busybox:latest
---> 8c2e06607696
Step 1 : ENV foo bar
---> Running in f46c59e9bdd6
---> 582bacbe7aaa
Once the build completes, you can see the new images returned by 
docker images
and you can launch a container based on it to check that the container has the envi‐
ronment variable 
foo
set to 
bar
:
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
busybox2 latest 582bacbe7aaa 6 seconds ago 2.433 MB
busybox latest 8c2e06607696 3 months ago 2.433 MB
$ docker run busybox2 env | grep foo
foo=bar
See Also
• Dockerfile 
reference

Chapter 2
, which covers image creation and sharing
1.15 Using Supervisor to Run WordPress in a Single
Container
Problem
You know how to link containers together (see 
Recipe 1.16
), and would like to run all
services needed for your application in a single container. Specifically for running
WordPress, you would like to run MySQL and HTTPD at the same time in a con‐
tainer. Because Docker executes foreground processes, you need to figure out a way
to run multiple “foreground” processes simultaneously.
Solution
Use 
Supervisor
to monitor and run both MySQL and HTTPD. Supervisor is not an
init system, but is meant to control multiple processes and is run like any other pro‐
gram.
1.15 Using Supervisor to Run WordPress in a Single Container | 25


This recipe is an example of using Supervisor to run multiple pro‐
cesses in a container. It can be used as the basis to run any number
of services via a single Docker image (e.g., SSH, Nginx). The Word‐
Press setup detailed in this recipe is a minimum viable setup, not
meant for production use.
The example files can be found on 
GitHub
. They include a Vagrantfile to start a vir‐
tual machine that runs Docker, a Dockerfile that defines the image being created, a
Supervisor configuration file (
supervisord.conf
), and a WordPress configuration file
(
wp-config.php
).
If you do not want to use Vagrant, you can take the Dockerfile,
supervisord
, and WordPress configuration files and set things up
on your own Docker host.
To run WordPress, you will need to install MySQL, Apache 2 (i.e., 
httpd
), and PHP,
and grab the latest WordPress release. You will need to create a database for Word‐
Press. In the configuration file used in this recipe, the WordPress database user is
root
, its password is 
root
, and the database is 
wordpress
. Change these settings to
your liking in the 
wp-config.php
file and edit the Dockerfile accordingly.
A Dockerfile, a manifest that describes how a Docker image is built, is described in
detail in the following chapters. If this is your first use of a Dockerfile, you can use it
as is and come back to it later (see 
Recipe 2.3
for an introduction to Dockerfiles):
FROM ubuntu:14.04
RUN apt-get update && apt-get -y install \
apache2 \
php5 \
php5-mysql \
supervisor \
wget
RUN echo 'mysql-server mysql-server/root_password password root' | \
debconf-set-selections && \
echo 'mysql-server mysql-server/root_password_again password root' | \
debconf-set-selections
RUN apt-get install -qqy mysql-server
RUN wget http://wordpress.org/latest.tar.gz && \
tar xzvf latest.tar.gz && \
cp -R ./wordpress/* /var/www/html && \
rm /var/www/html/index.html

Download 6,31 Mb.

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