Docker Cookbook


| Chapter 1: Getting Started with Docker



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

28 | Chapter 1: Getting Started with Docker


$ docker run --name wordpress --link mysqlwp:mysql -p 80:80 -d wordpress
Both containers should be running in the background, with port 80 of the WordPress
container mapped to port 80 of the host:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED ...
e1593e7a20df wordpress:latest "/entrypoint.sh apac About a minute ago ...
d4be18e33153 mysql:latest "/entrypoint.sh mysq 5 minutes ago ...
... STATUS PORTS NAMES
... Up About a minute 0.0.0.0:80->80/tcp wordpress
... Up 5 minutes 3306/tcp mysqlwp
Open a browser a">t 
">http://
and it should show the WordPress installation
screen with the language selection window, as shown in 
Figure 1-10
. If you go
through the WordPress setup, you will then have a fully functional WordPress site
running with two linked containers.
Figure 1-10. Working WordPress site within containers
Discussion
The two images for WordPress and MySQL are official images maintained by the
WordPress and MySQL communities. Each page on the Docker Hub provides addi‐
tional documentation for configuration of containers started with those images.
1.16 Running a WordPress Blog Using Two Linked Containers | 29


Do not forget to read the WordPress image 
documentation
 and the
MySQL image 
documentation
.
Of interest is that you can create a database and a user with appropriate privileges to
manipulate that database by using a few environment variables: 
MYSQL_DATABASE
,
MYSQL_USER
, and 
MYSQL_PASSWORD
. In the preceding example, WordPress is run as the
root
MySQL user and this is far from best practice. It would be better to create a 
word
press
database and a user for it, like so:
$ docker run --name mysqlwp -e MYSQL_ROOT_PASSWORD=wordpressdocker \
-e MYSQL_DATABASE=wordpress \
-e MYSQL_USER=wordpress \
-e MYSQL_PASSWORD=wordpresspwd \
-d mysql
If you need to remove all existing containers, you can use a short‐
cut making use of a subshell command:
$ docker stop $(docker ps -q)
$ docker rm -v $(docker ps -aq)
The 
-v
option of 
docker rm
removes the volume defined by the
MySQL image.
Once the database container is running, you run the WordPress container and specify
the database tables you defined:
$ docker run --name wordpress --link mysqlwp:mysql -p 80:80 \
-e WORDPRESS_DB_NAME=wordpress \
-e WORDPRESS_DB_USER=wordpress \
-e WORDPRESS_DB_PASSWORD=wordpresspwd \
-d wordpress

Download 6,31 Mb.

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