Docker Cookbook


| Chapter 1: Getting Started with Docker



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

22 | Chapter 1: Getting Started with Docker


See Also
• Docker run 
reference
1.13 Creating, Starting, Stopping, and Removing
Containers
Problem
You know how to start containers and to run them in detached mode. You would like
to learn the basic commands to manage the entire life cycle of a container.
Solution
Use the 
create

start

stop

kill
, and 
rm
commands of the Docker CLI. Find the
appropriate usage of each command with the 
-h
or 
--h
option or by typing the com‐
mand with no arguments (e.g., 
docker create
).
Discussion
In 
Recipe 1.12
, you started a container automatically with 
docker run
. You can also
stage a container with the 
docker create
command. Using the same example of run‐
ning a simple HTTP server, the only difference will be that you will not specify the 
-d
option. Once staged, the container will need to be started with 
docker start
:
$ docker create -P --expose=1234 python:2.7 python -m SimpleHTTPServer 1234
a842945e2414132011ae704b0c4a4184acc4016d199dfd4e7181c9b89092de13
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED ... NAMES
a842945e2414 python:2.7 "python -m SimpleHTT 8 seconds ago ... fervent_hodgkin
$ docker start a842945e2414
a842945e2414
$ docker ps
CONTAINER ID IMAGE COMMAND ... NAMES
a842945e2414 python:2.7 "python -m SimpleHTT ... fervent_hodgkin
To stop a running container, you have a choice between 
docker kill
(which will
send a 
SIGKILL
signal to the container) or 
docker stop
(which will send a 
SIGTERM
and after a grace period will send a 
SIGKILL
). The end result will be that the container
is stopped and is not listed in the list of running containers returned by 
docker ps

However, the container has not yet disappeared (i.e., the filesystem of the container is
still there); you could restart it with 
docker restart
or remove it forever with
docker rm
:

Download 6,31 Mb.

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