-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker.html
232 lines (153 loc) · 4.91 KB
/
docker.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
---
layout: default
---
<div id="content">
<h2 class="title">B-Translator With Docker</h2>
<p>Installing a B-Translator Server or Client in a Docker container has
some advantages, compared to installing it in a chroot environment.
For example:
</p><ul>
<li>
More platform independent (can be installed even on
<i>Mac-OS-X</i> or <i>Windows</i>).
</li>
<li>
Better isolation of the guest system from the host system.
</li>
<li>
Can easily run multiple instances of the server or client on the
same host (useful for development, testing, or resource
concentration), etc.
</li>
</ul>
<p>However you have to be familiar with the Docker concepts and tools,
and this adds more complexity. For more information about Docker,
installation instructions, tutorials etc. look at
<a href="https://docs.docker.com">https://docs.docker.com</a> . In this arcticle we will focus only on the
steps relevant to B-Translator.
</p>
<div id="outline-container-1" class="outline-2">
<h3 id="sec-1">Getting images </h3>
<div class="outline-text-2" id="text-1">
<p>
First we have to get the image of the system. This is basically the
root filesystem of the system, very similar to the root filesystem
in the case of chroot.
</p>
<pre class="example">docker search btranslator
docker pull btranslator/btr_client:v2.2
docker pull btranslator/btr_client:v2.2-openatrium
docker pull btranslator/btr_server:v2.2
docker images
</pre>
<p>
Docker images can be deleted with the command <code>docker rmi</code>:
</p>
<pre class="example">docker rmi btranslator/btr_client:v2.2 btranslator/btr_server:v2.2
</pre>
</div>
</div>
<div id="outline-container-2" class="outline-2">
<h3 id="sec-2">Creating containers </h3>
<div class="outline-text-2" id="text-2">
<p>
Create containers by running docker on an image, with these parameters:
</p>
<pre class="example">docker run -d --name=bcl --hostname=example.org \
-p 80:80 -p 443:443 btranslator/btr_client:v2.2
</pre>
<p>
If we now check the list of containers with <code>docker ps -a</code> we will
see there the container with name <b>bcl</b>. Also, the host ports <b>80</b>
and <b>443</b> (HTTP and HTTPS) are mapped to the same ports of the
container.
</p>
<p>
Now that the docker container is running, we can stop and start it
like this:
</p>
<pre class="example">docker stop bcl
docker start bcl
docker restart bcl
</pre>
<p>
If needed, we can create other containers from the same image:
</p>
<pre class="example">docker run -d --name=bcl1 -p 81:80 -p 444:443 btranslator/btr_client:v2.2
docker run -d --name=bcl2 -p 82:80 -p 445:443 btranslator/btr_client:v2.2</pre>
<p>
We can delete containers with <code>docker rm</code>, but we have to stop them
first:
</p>
<pre class="example">docker stop bcl1 bcl2
docker rm bcl1 bcl2
</pre>
</div>
</div>
<div id="outline-container-3" class="outline-2">
<h3 id="sec-3">Accessing the shell </h3>
<div class="outline-text-2" id="text-3">
<p>
In order to access the shell of a running Docker container, we have
to install <code>docker-enter</code>:
</p>
<pre class="example">docker run -v /usr/local/bin:/target jpetazzo/nsenter
</pre>
<p>
Then we can access the shell of a container like this:
</p>
<pre class="example">docker-enter bcl
</pre>
<p>
From this shell we can check configuration files, logs, etc.
</p>
<p>
See also this article:
<a href="http://blog.docker.com/2014/06/why-you-dont-need-to-run-sshd-in-docker/">http://blog.docker.com/2014/06/why-you-dont-need-to-run-sshd-in-docker/</a>
</p>
</div>
</div>
<div id="outline-container-4" class="outline-2">
<h3 id="sec-4">Configuration of B-Translator </h3>
<div class="outline-text-2" id="text-4">
<p>
The image that we have used to create and start the container has a
standard configuration, with default domains, passwords, etc. We need
to customize these settings.
</p>
<pre class="example">docker-enter bcl
cd /usr/local/src/btr_client/
vim install/settings.sh
install/{config.sh,settings.sh}
</pre>
</div>
</div>
<div id="outline-container-5" class="outline-2">
<h3 id="sec-5">Starting a sshd server inside the container </h3>
<div class="outline-text-2" id="text-5">
<p>
We want to start a sshd server on port 2201 inside the container,
but when we created the container with <code>docker run</code> we did not think
about forwarding this port. We have to destroy this container and
create a new one, with an addition <code>-p</code> option for the
port 2201. But first we should use the command <code>docker commit</code> to
save to a new image any configurations and data that we already have
in this container.
</p>
<pre class="example">docker stop bcl
docker commit bcl btr_client:1
docker images
docker rm bcl
docker run -d --name=bcl --hostname=example.org \
-p 80:80 -p 443:443 -p 2201:2201 btr_client:1
</pre>
<p>
Now we can enter the container and start the sshd server:
</p>
<pre class="example">docker-enter bcl
cd /usr/local/src/btr_client/
dev/install-sshd.sh 2201
</pre>
</div>
</div>
</div>