Docker Cookbook


| Chapter 1: Getting Started with Docker



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

20 | Chapter 1: Getting Started with Docker
www.allitebooks.com


Containers are based on images. An image needs to be passed to the 
docker run
command. In the preceding example, you specify an image called 
busybox
. Docker
does not have this image locally and 
pulls
it from a public registry. A 
registry
is a cata‐
log of Docker images that the Docker client can communicate with and download
images from. Once the image is pulled, Docker starts a container and executes the
echo hello world
command. Congratulations—you ran your first container.
Discussion
If you list the running containers, you will see that none are running. That’s because
as soon as the container did its job (echoing hello world) it stopped. However, it is
not totally gone, and you can see it with the 
docker ps -a
command:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$ docker ps -a
CONTAINER ID IMAGE COMMAND ... PORTS NAMES
8f7089b187e8 busybox:latest "echo hello world" ... thirsty_morse
You see that the container has an ID (8f7089b187e8) and an image (
busybox:latest
) as
well as a name, and you see the command that it ran. You can permanently remove
this container with 
docker rm 8f7089b187e8
. The image that you used was downloa‐
ded locally, and 
docker images
returns it:
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
busybox latest e72ac664f4f0 9 weeks ago 2.433 MB
If no running or stopped containers are using this image, you can remove it with
docker rmi busybox
.
Running 
echo
is fun but getting a terminal session within a container is even better.
Try to run a container that executes 
/bin/bash
. You will need to use the 
-t
and 
-i
options to get a proper interactive session and while we are at it, let’s use an Ubuntu
image:
$ docker run -t -i ubuntu:14.04 /bin/bash
Unable to find image 'ubuntu:14.04' locally
ubuntu:14.04: The image you are pulling has been verified
01bf15a18638: Pull complete
30541f8f3062: Pull complete
e1cdf371fbde: Pull complete
9bd07e480c5b: Pull complete
511136ea3c5a: Already exists
Status: Downloaded newer image for ubuntu:14.04
root@6f1050d21b41:/#
You see that Docker pulled the 
Ubuntu:14.04
image composed of several layers, and
you got a session as root within a container. The prompt gives you the ID of the con‐

Download 6,31 Mb.

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