Docker Cookbook


| Chapter 4: Docker Configuration and Development



Download 6,31 Mb.
Pdf ko'rish
bet100/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   96   97   98   99   100   101   102   103   ...   260
Bog'liq
Docker Cookbook

114 | Chapter 4: Docker Configuration and Development


docker-enter
is nothing more than a wrapper around 
nsenter
. You could use 
nsen
ter
directly after finding the process ID of the container with 
docker inspect
,
like so:
$ docker inspect --format {{.State.Pid}} sleep
9302
$ sudo nsenter --target 9302 --mount --uts --ipc --net --pid
root@db9675525fab:/#
Discussion
Starting with Docker 1.3, you do not need to use 
nsenter
; use 
docker exec
instead:
$ docker exec -h
Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
Run a command in a running container
-d, --detach=false Detached mode: run command in the background
--help=false Print usage
-i, --interactive=false Keep STDIN open even if not attached
-t, --tty=false Allocate a pseudo-TTY
See Also
• GitHub page from 
Jerome Petazzoni
 
nsenter
repository
4.6 Introducing runc
Problem
You want to become familiar with the upcoming standard around the container for‐
mat and runtime 
runc
.
Solution
The Open Container Project (OCP) was established in June 2015, and the specifica‐
tions coming from that project are still not done. However, Docker Inc. donated its
libcontainer
codebase as an early implementation of a standard runtime for contain‐
ers. This runtime is called 
runc
.
The OCP was just launched, so the specifications are not out yet.
Expect many changes until the specifications and reference imple‐
mentations are considered stable and official.
4.6 Introducing runc | 115


This recipe will give you a quick feel for 
runc
, including instructions to compile the
Go codebase. As always, I prepared a Vagrant box that gives you a Docker host, a Go
1.4.2 installation, and a clone of the 
runc
code. To get started with this box, use the
following:
$ git clone https://github.com/how2dock/docbook.git
$ cd dockbook/ch04/runc
$ vagrant up
$ vagrant ssh
Once you are on a terminal inside this VM, you need to grab all the dependencies of
runc
by using the 
go get
command. Once this completes, you can build 
runc
and
install. Verify that you have a running 
runc
in your path:
Expect a change in the build process sometime soon. Most likely
the build will use Docker itself.
$ cd go/src
$ go get github.com/opencontainers/runc
$ cd github.com/opencontainers/runc/
$ make
$ sudo make install
$ runc -v
runc version 0.2
To run a container with 
runc
, you need a root filesystem describing your container
image. The easiest way to get one is to use Docker itself and the 
docker export
com‐
mand. So let’s pull a Docker image, start a container, and export it to a tarball:
$ cd ~
$ mkdir foobar
$ cd foobar
$ docker run --name foobar -d ubuntu:14.04 sleep 30
$ docker export -o foobar.tar foobar
$ sudo -xf foobar.tar
$ rm foobar.tar
To run this container, you need to generate a configuration file. This is most easily
done with the 
runc spec
command. To get a container started quickly, you will need
to get only one change, which is the location of the root filesystem. In that JSON file,
edit the path to it; you see an excerpt here:
$ runc spec > config.json
$ vi config.json
...
"root": {
"path": "./",

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   96   97   98   99   100   101   102   103   ...   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