Docker Cookbook


Keeping Changes Made to a Container by Committing



Download 6,31 Mb.
Pdf ko'rish
bet40/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   36   37   38   39   40   41   42   43   ...   260
Bog'liq
Docker Cookbook

2.1 Keeping Changes Made to a Container by Committing
to an Image
Problem
After making some changes inside a container, you decide that you would like to keep
those changes. You do not want to lose those changes after you exit or stop the con‐
tainer, and you would like to reuse this type of container as a basis for others.
Solution
Commit the changes that you made by using the 
docker commit
command and
define a new image.
Let’s start a container with an interactive bash shell and update the packages in it:
$ docker run -t -i ubuntu:14.04 /bin/bash
root@69079aaaaab1:/# apt-get update
When you exit the container, it stops running, but it is still available to you until you
remove it entirely with 
docker rm
. So before you do this, you can commit the
changes made to the container and create a new image, 
ubuntu:update
. The name of
the image is 
ubuntu
, and you add the tag 
update
 (see 
Recipe 2.6
) to mark the differ‐
ence from the 
ubuntu:latest
image:
$ docker commit 69079aaaaab1 ubuntu:update
13132d42da3cc40e8d8b4601a7e2f4dbf198e9d72e37e19ee1986c280ffcb97c
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu update 13132d42da3c 5 days ago 213 MB
...
You can now safely remove the stopped container and you will be able to start new
ones based on the 
ubuntu:update
image.
38 | Chapter 2: Image Creation and Sharing


Discussion
You can inspect the changes that have been made inside this container with the
docker diff
command:
$ docker diff 69079aaaaab1
C /root
A /root/.bash_history
C /tmp
C /var
C /var/cache
C /var/cache/apt
D /var/cache/apt/pkgcache.bin
D /var/cache/apt/srcpkgcache.bin
C /var/lib
C /var/lib/apt
C /var/lib/apt/lists
...
A
means that the file or directory listed was added, 
C
means that there was a change
made, and 
D
means that it was deleted.

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   36   37   38   39   40   41   42   43   ...   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