Skip to content

Commit 5872d34

Browse files
authored
Merge pull request #1440 from allencloud/polish-rich-container-doc
docs: add more details on rich container
2 parents c1d3a46 + b0db23e commit 5872d34

File tree

2 files changed

+62
-52
lines changed

2 files changed

+62
-52
lines changed

docs/features/pouch_with_rich_container.md

Lines changed: 62 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# Rich Container
22

3-
Rich container is a very useful container mode when containerizing applications. This mode helps technical staff to complete packaging fat applications almost with no effort. It provides efficient ways to equip more basic software or system services except for target application in a single container . Then applications in containers could be running as smoothly as usual in VM or physical machine. This is a more generalized application-centric mode. This mode brings no invasiveness at all to both developers and operators. Especially for operators, they could have abilities to maintain applications in container with all essential tools or service processes they may need as usual.
3+
Rich container is a very useful container mode when containerizing applications. This mode helps technical staff to complete packaging fat applications almost with no effort. It provides efficient ways to equip more basic software or system services except for target application in a single container. Then applications in containers could be running as smoothly as usual in VM or physical machine. This is a more generalized application-centric mode. This mode brings no invasiveness at all to both developers and operators. Especially for operators, they could have abilities to maintain applications in container with all essential tools or service processes they may need as usual.
44

55
Rich container mode is not the default mode PouchContainer provides. It is an additional mode PouchContainer brings to extend users' container experience. Users can still manage ordinary containers by switching rich container flag off.
66

7+
In a word, rich container can help enterprise to achieve the following two goals:
8+
9+
* be compatible with legacy operating system;
10+
* still take advantanges of image concept to speed up application delivery.
11+
712
## Scenario
813

914
Container technology and orchestration platforms have turned quite popular right now. They both offer much better environment for applications. Despite this, we have to say containerization is the first step for enterprises to embrace container-related technologies, such as container, orchestration, service mesh and so on. It is quite a real problem to move traditional application into containers. Although some simple applications are always showing friendly to container, more traditional and complicated enterprise applications may not so lucky. These traditional applications are usually coupled with underlying infrastructure, such as architecture of machine, old kernels, even certain software out of maintenance as well. Definitely, strong coupling is not everyone's dish. It is the initiator on the road of digital transformation in enterprises. So, all the industry is seeking one possible way to work it out. The way docker provides is one, but not the best. In the past 7 years, Alibaba has also experienced the same issue. Fortunately, rich container mode is a much better way to handle this.
@@ -12,6 +17,14 @@ Developers have their own programming style. Their work is to create useful appl
1217

1318
Operators have a sacred duty to guard normal running of the applications. For the sake of business running in applications, technology must show enough respect for operator's tradition. Environment change is not a good message when debugging and solving issue online. Rich container mode can ensure that environment in rich container in totally the same as that in traditional VM or physical machine. If operator needs some system tools, they are located there still. If some pre and post hooks should take effect, just set them when starting rich containers. If some issues happen inside, system services started by rich container can fix them just like self-healing.
1419

20+
## Architecture
21+
22+
Rich container mode is compatible with the legacy operation ways for operation team. The following architecture graph shows how to achieve this:
23+
24+
![pouch_with_rich_container](../static_files/pouch_with_rich_container.png)
25+
26+
To be more detailed, rich container promises to be compatible with oci-compatible image. When running a rich container, pouchd would take image filesystem as the rootfs of rich container itself. In the runtime of inner container, besides inner applications and system servcies, there are also some hooks like prestart hook and poststop hook. The previous one focuses on how to prepare or intialize the environment before systemd and related process run. And the latter one is almost on cleanup work when container stops.
27+
1528
## Get started
1629

1730
Users can start rich container mode in PouchContainer quite easily. Provided that we need to running an ordinary image in rich container mode via PouchContainer, there are only two flags we may add: `--rich`,`--rich-mode`and `--initscript`. Here are more description about both flags:
@@ -32,25 +45,23 @@ Here is a simple example for rich container mode using dumb-init to init contain
3245

3346
1. Install dumb-init as following:
3447

35-
```shell
36-
# wget -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64
37-
# chmod +x /usr/bin/dumb-init
38-
39-
```
48+
```shell
49+
# wget -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64
50+
# chmod +x /usr/bin/dumb-init
51+
```
4052

4153
2. Run a container with rich mode:
4254

43-
```shell
44-
#pouch run -d --rich --rich-mode dumb-init registry.hub.docker.com/library/busybox:latest sleep 10000
45-
f76ac1e49e9407caf5ad33c8988b44ff3690c12aa98f7faf690545b16f2a5cbd
46-
47-
#pouch exec f76ac1e49e9407caf5ad33c8988b44ff3690c12aa98f7faf690545b16f2a5cbd ps -ef
48-
PID USER TIME COMMAND
49-
1 root 0:00 /usr/bin/dumb-init -- sleep 10000
50-
7 root 0:00 sleep 10000
51-
8 root 0:00 ps -ef
55+
```shell
56+
#pouch run -d --rich --rich-mode dumb-init registry.hub.docker.com/library/busybox:latest sleep 10000
57+
f76ac1e49e9407caf5ad33c8988b44ff3690c12aa98f7faf690545b16f2a5cbd
5258

53-
```
59+
#pouch exec f76ac1e49e9407caf5ad33c8988b44ff3690c12aa98f7faf690545b16f2a5cbd ps -ef
60+
PID USER TIME COMMAND
61+
1 root 0:00 /usr/bin/dumb-init -- sleep 10000
62+
7 root 0:00 sleep 10000
63+
8 root 0:00 ps -ef
64+
```
5465

5566
### Using systemd or sbin-init
5667

@@ -59,42 +70,41 @@ As shown below, centos image has both of them.
5970
Also `--privileged` is required in this situation. An example of systemd and sbin-init is as following:
6071

6172
```
62-
#cat /tmp/1.sh
63-
#! /bin/sh
64-
echo $(cat) >/tmp/xxx
65-
66-
#pouch run -d -v /tmp:/tmp --privileged --rich --rich-mode systemd --initscript /tmp/1.sh registry.hub.docker.com/library/centos:latest /usr/bin/sleep 10000
67-
3054125e44443fd5ee9190ee49bbca0a842724f5305cb05df49f84fd7c901d63
68-
69-
#pouch exec 3054125e44443fd5ee9190ee49bbca0a842724f5305cb05df49f84fd7c901d63 ps aux
70-
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
71-
root 1 7.4 0.0 42968 3264 ? Ss 05:29 0:00 /usr/lib/systemd/systemd
72-
root 17 0.0 0.0 10752 756 ? Ss 05:29 0:00 /usr/lib/systemd/systemd-readahead collect
73-
root 18 3.2 0.0 32740 2908 ? Ss 05:29 0:00 /usr/lib/systemd/systemd-journald
74-
root 34 0.0 0.0 22084 1456 ? Ss 05:29 0:00 /usr/lib/systemd/systemd-logind
75-
root 36 0.0 0.0 7724 608 ? Ss 05:29 0:00 /usr/bin/sleep 10000
76-
dbus 37 0.0 0.0 24288 1604 ? Ss 05:29 0:00 /bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
77-
root 45 0.0 0.0 47452 1676 ? Rs 05:29 0:00 ps aux
78-
79-
#cat /tmp/xxx
80-
{"ociVersion":"1.0.0","id":"3054125e44443fd5ee9190ee49bbca0a842724f5305cb05df49f84fd7c901d63","status":"","pid":125745,"bundle":"/var/lib/pouch/containerd/state/io.containerd.runtime.v1.linux/default/3054125e44443fd5ee9190ee49bbca0a842724f5305cb05df49f84fd7c901d63"}
81-
82-
#pouch run -d -v /tmp:/tmp --privileged --rich --rich-mode sbin-init --initscript /tmp/1.sh registry.hub.docker.com/library/centos:latest /usr/bin/sleep 10000
83-
c5b5eef81749ce00fb68a59ee623777bfecc8e07c617c0601cc56e4ae8b1e69f
84-
85-
#pouch exec c5b5eef81749ce00fb68a59ee623777bfecc8e07c617c0601cc56e4ae8b1e69f ps aux
86-
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
87-
root 1 7.4 0.0 42968 3260 ? Ss 05:30 0:00 /sbin/init
88-
root 17 0.0 0.0 10752 752 ? Ss 05:30 0:00 /usr/lib/systemd/systemd-readahead collect
89-
root 20 3.2 0.0 32740 2952 ? Ss 05:30 0:00 /usr/lib/systemd/systemd-journald
90-
root 34 0.0 0.0 22084 1452 ? Ss 05:30 0:00 /usr/lib/systemd/systemd-logind
91-
root 35 0.0 0.0 7724 612 ? Ss 05:30 0:00 /usr/bin/sleep 10000
92-
dbus 36 0.0 0.0 24288 1608 ? Ss 05:30 0:00 /bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
93-
root 45 0.0 0.0 47452 1676 ? Rs 05:30 0:00 ps aux
94-
95-
#cat /tmp/xxx
96-
{"ociVersion":"1.0.0","id":"c5b5eef81749ce00fb68a59ee623777bfecc8e07c617c0601cc56e4ae8b1e69f","status":"","pid":127183,"bundle":"/var/lib/pouch/containerd/state/io.containerd.runtime.v1.linux/default/c5b5eef81749ce00fb68a59ee623777bfecc8e07c617c0601cc56e4ae8b1e69f"}
97-
73+
#cat /tmp/1.sh
74+
#! /bin/sh
75+
echo $(cat) >/tmp/xxx
76+
77+
#pouch run -d -v /tmp:/tmp --privileged --rich --rich-mode systemd --initscript /tmp/1.sh registry.hub.docker.com/library/centos:latest /usr/bin/sleep 10000
78+
3054125e44443fd5ee9190ee49bbca0a842724f5305cb05df49f84fd7c901d63
79+
80+
#pouch exec 3054125e44443fd5ee9190ee49bbca0a842724f5305cb05df49f84fd7c901d63 ps aux
81+
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
82+
root 1 7.4 0.0 42968 3264 ? Ss 05:29 0:00 /usr/lib/systemd/systemd
83+
root 17 0.0 0.0 10752 756 ? Ss 05:29 0:00 /usr/lib/systemd/systemd-readahead collect
84+
root 18 3.2 0.0 32740 2908 ? Ss 05:29 0:00 /usr/lib/systemd/systemd-journald
85+
root 34 0.0 0.0 22084 1456 ? Ss 05:29 0:00 /usr/lib/systemd/systemd-logind
86+
root 36 0.0 0.0 7724 608 ? Ss 05:29 0:00 /usr/bin/sleep 10000
87+
dbus 37 0.0 0.0 24288 1604 ? Ss 05:29 0:00 /bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
88+
root 45 0.0 0.0 47452 1676 ? Rs 05:29 0:00 ps aux
89+
90+
#cat /tmp/xxx
91+
{"ociVersion":"1.0.0","id":"3054125e44443fd5ee9190ee49bbca0a842724f5305cb05df49f84fd7c901d63","status":"","pid":125745,"bundle":"/var/lib/pouch/containerd/state/io.containerd.runtime.v1.linux/default/3054125e44443fd5ee9190ee49bbca0a842724f5305cb05df49f84fd7c901d63"}
92+
93+
#pouch run -d -v /tmp:/tmp --privileged --rich --rich-mode sbin-init --initscript /tmp/1.sh registry.hub.docker.com/library/centos:latest /usr/bin/sleep 10000
94+
c5b5eef81749ce00fb68a59ee623777bfecc8e07c617c0601cc56e4ae8b1e69f
95+
96+
#pouch exec c5b5eef81749ce00fb68a59ee623777bfecc8e07c617c0601cc56e4ae8b1e69f ps aux
97+
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
98+
root 1 7.4 0.0 42968 3260 ? Ss 05:30 0:00 /sbin/init
99+
root 17 0.0 0.0 10752 752 ? Ss 05:30 0:00 /usr/lib/systemd/systemd-readahead collect
100+
root 20 3.2 0.0 32740 2952 ? Ss 05:30 0:00 /usr/lib/systemd/systemd-journald
101+
root 34 0.0 0.0 22084 1452 ? Ss 05:30 0:00 /usr/lib/systemd/systemd-logind
102+
root 35 0.0 0.0 7724 612 ? Ss 05:30 0:00 /usr/bin/sleep 10000
103+
dbus 36 0.0 0.0 24288 1608 ? Ss 05:30 0:00 /bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
104+
root 45 0.0 0.0 47452 1676 ? Rs 05:30 0:00 ps aux
105+
106+
#cat /tmp/xxx
107+
{"ociVersion":"1.0.0","id":"c5b5eef81749ce00fb68a59ee623777bfecc8e07c617c0601cc56e4ae8b1e69f","status":"","pid":127183,"bundle":"/var/lib/pouch/containerd/state/io.containerd.runtime.v1.linux/default/c5b5eef81749ce00fb68a59ee623777bfecc8e07c617c0601cc56e4ae8b1e69f"}
98108
```
99109

100110
## Underlying Implementation
173 KB
Loading

0 commit comments

Comments
 (0)