Docker Cookbook


Creating, Starting, Stopping, and Removing Containers | 23



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

1.13 Creating, Starting, Stopping, and Removing Containers | 23


$ docker restart a842945e2414
a842945e2414
$ docker ps
CONTAINER ID IMAGE COMMAND ... NAMES
a842945e2414 python:2.7 "python -m SimpleHTT ... fervent_hodgkin
$ docker kill a842945e2414
a842945e2414
$ docker rm a842945e2414
a842945e2414
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
If you have a lot of stopped containers that you would like to
remove, use a subshell to do it in one command. The 
-q
option of
docker ps
will return only the containers’ IDs:
$ docker rm $(docker ps -a -q)
1.14 Building a Docker Image with a Dockerfile
Problem
You understand how to download images from a publicly available Docker registry
but you would like to build your own Docker images.
Solution
Use a Dockerfile. A 
Dockerfile
is a text file that describes the steps that Docker needs
to take to prepare an image—including installing packages, creating directories, and
defining environment variables, among other things. In 
Chapter 2
, we will expand
much further about Dockerfiles and image creation. This recipe covers the basic con‐
cept of building an image.
As a toy example, let’s say you want to create an image based on the 
busybox
image
but that you want to define an environment variable. The 
busybox
image is a Docker
image that contains the 
busybox
 binary, which combines most Unix utilities in a sin‐
gle binary. Create the following text file named 
Dockerfile
in an empty working direc‐
tory:
FROM busybox
ENV foo=bar
Then to build a new image called 
busybox2
, you use the 
docker build
command like
so:
$ docker build -t busybox2 .
Sending build context to Docker daemon 2.048 kB
Step 0 : FROM busybox

Download 6,31 Mb.

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