Docker Cookbook


Writing Your First Dockerfile | 41



Download 6,31 Mb.
Pdf ko'rish
bet43/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   39   40   41   42   43   44   45   46   ...   260
Bog'liq
Docker Cookbook

2.3 Writing Your First Dockerfile | 41


CMD
as an argument to 
docker run
. Let’s build a new image by using the 
CMD
instruc‐
tion, like so:
FROM ubuntu:14.04
CMD ["/bin/echo" , "Hi Docker !"]
Let’s build it and run it:
$ docker build .
...
$ docker run eff764828551
Hi Docker !
In the preceding build command, you specified the root directory.
The Dockerfile that you just created was automatically used for the
build. If you want to do a build of an image based on a Dockerfile
that is in a different location, you use the 
-f
option of 
docker
build
and specify the path.
It looks the same, but if you pass a new executable as an argument to the 
docker run
command, this command will be executed instead of the 
/bin/echo
defined in the
Dockerfile:
$ docker run eff764828551 /bin/date
Thu Dec 11 02:49:06 UTC 2014
Discussion
A Dockerfile is a text file that represents the way a Docker image is built and what
happens when a container is started with this image. Starting with three simple
instructions, you can build a fully functioning container: 
FROM

ENTRYPOINT

CMD
. Of
course, this is quite limited in this recipe. Read the Dockerfile 
reference
 to learn
about all the other instructions, or go to 
Recipe 2.4
for a more detailed example.
The CentOS project maintains a large set of Dockerfile examples.
Check out this 
repository
and run a few of their examples to get
more familiar with Dockerfile files.
Remember that 
CMD
can be overwritten by an argument to 
docker run
, while 
ENTRY
POINT
can be overwritten only by using the 
--entrypoint
option of 
docker run
.
Also, you saw that after a command is finished, the container exits. A process that
you want to run in a container needs to run in the foreground; otherwise, the con‐
tainer will stop.

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   39   40   41   42   43   44   45   46   ...   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