Docker Cookbook


| Chapter 2: Image Creation and Sharing



Download 6,31 Mb.
Pdf ko'rish
bet46/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   42   43   44   45   46   47   48   49   ...   260
Bog'liq
Docker Cookbook

44 | Chapter 2: Image Creation and Sharing


This creates a 
flask
Docker image:
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
flask latest d381310506ed 4 days ago 354.6 MB
cookbook echo e778362ca7cf 4 days ago 192.7 MB
ubuntu 14.04 9bd07e480c5b 10 days ago 192.7 MB
To run the application, you use the 
-d
option of 
docker run
, which daemonizes the
container, and you also use the 
-P
option of 
docker run
to let Docker choose a port
on the Docker host that will be mapped to the exposed port specified in the Docker‐
file (e.g., 5000):
$ docker run -d -P flask
5ac72ed12a72f0e2bec0001b3e78f11660905d20f40e670d42aee292263cb890
$ docker ps
CONTAINER ID IMAGE COMMAND ... PORTS
5ac72ed12a72 flask:latest "python /tmp/hello.p ... 0.0.0.0:49153->5000/tcp
The container returns, it is daemonized, and you are not logged in to an interactive
shell. 
PORTS
shows a mapping between port 5000 of the container and port 49153 of
the Docker host. A simple 
curl
 to 
http://localhost:49153/hi
returns 
Hello World
, or
you can open your browser to the same URL.
If you are using Boot2Docker, you will have to use the IP address of
the bridge network, instead of 
localhost
. If you do want to use
localhost
, add port forwarding rules in VirtualBox.
Discussion
Since your Dockerfile specified a command to run via 
CMD
, you do not need to specify
a command after the name of the image to use. However, you can override this com‐
mand and start the container in interactive mode by starting a bash shell like so:
$ docker run -t -i -P flask /bin/bash
root@fc1514ced93e:/# ls -l /tmp
total 4
-rw-r--r-- 1 root root 194 Dec 8 13:41 hello.py
root@fc1514ced93e:/#

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   42   43   44   45   46   47   48   49   ...   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