File: Dockerfile.howto

package info (click to toggle)
axiom 20170501-4
  • links: PTS
  • area: main
  • in suites: buster, sid
  • size: 1,048,504 kB
  • sloc: lisp: 3,600; makefile: 505; cpp: 223; ansic: 138; sh: 96
file content (222 lines) | stat: -rw-r--r-- 6,080 bytes parent folder | download
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
This is how I made an Axiom docker image.

It is actually rather simple, although it takes a fair amount
of reading to make it "simple". Let me smooth the path for you.

On ubuntu, as root (docker wants to be root initially)

1) there is an app called docker which is not the docker we want

  apt-get remove docker

2) we need to install docker

  apt-get install -y docker.io

3) next we need to fetch a container (actually many containers)

  docker pull ubuntu

4) see what images you have

  docker images 

5) select one of them. I chose ubuntu 12.04 since that version
   has worked well in the past for me. The exact image can be
   selected using the IMAGE ID column.

7) make a working directory. Files in this directory will be available
   during the docker build step.

   mkdir /root/docker

6) make a tar image which would be the subtree you would
   get from an installed version of your program. Axiom installs are
   in /usr/local/axiom so I did

   cd /usr/local
   tar -zcf /root/docker/axiom.tgz axiom

7) copy your shell script to /root/docker

   cd /root/docker
   cp /usr/local/bin/axiom .

8) make a Dockerfile file

   emacs -nw Dockerfile

9) add a set of docker commands (by convention they are uppercase)

   # ubuntu 12.04
   FROM 28a945b4333c
   MAINTAINER Tim Daly <daly@axiom-developer.org>
   # update the image to the latest repos
   RUN apt-get update
   # for X11 connections to hyperdoc
   RUN apt-get install -y libxpm-dev gcc
   # untar the program into the image at /usr/local
   ADD axiom.tgz /usr/local
   # put the command in the path
   ADD axiom /usr/local/bin
   # make the axiom command executable by everyone
   RUN chmod a+x /usr/local/bin/axiom

9) save the Dockerfile (note that case is important)

10) run the docker build

   cd /root/docker
   docker build .
   

11) find out the ID of the latest image you just made, which is
    the hash code under CONTAINER ID

   docker ps -l

CONTAINER ID
12345abcde

12) commit the container with all of the changes (Note that
    doing anything with the container interatively will lose
    changes you don't commit)

   docker commit 12345abcde daly/axiom

13) check that you now have a new image

   docker images

14) create a userid on the docker hub.docker.com (e.g. daly)

15) push the daly/axiom image to the hub

   docker login
   docker push daly/axiom


The whole process should take about 1 hour. Some more details....

================================================================
3) next we need to fetch a container (actually many containers)

  docker pull ubuntu

> If you know the IMAGE ID you don't have to do the pull
> because the docker build command will do it for you.




================================================================
5) select one of them. I chose ubuntu 12.04 since that version
   has worked well in the past for me. The exact image can be
   selected using the IMAGE ID column.

>The key advantage of Docker is that you can isolate yourself
from the underlying operating system. I chose ubuntu 12.04
>because that's the opsys on my master machine.




================================================================
7) make a working directory. Files in this directory will be available
   during the docker build step.

   mkdir /root/docker

>Be careful what you put in this directory. The whole directory 
>will be cloned so the build process can import files. You don't
>want to import sensitive information.




================================================================
6) make a  tar image which would be the subtree you would
   get from an installed version of your program. Axiom installs are
   in /usr/local/axiom so I did

   cd /usr/local
   tar -zcf /root/docker/axiom.tgz axiom

>The docker build process knows to untar/decompress tgz files
>so this will be decompressed automatically




================================================================
9) add a set of docker commands (by convention they are uppercase)

>The docker build runs by starting the image and then executing
>the commands from the Dockerfile in the image. The files in
>the named subdirectory are directly accessed so make sure you
>copy what you need to a subdirectory (which I called docker)

>Note that I used the exact IMAGE ID I wanted (ubuntu 12.04)
>docker will fetch that image if it is not locally available.
   # ubuntu 12.04
   FROM 28a945b4333c

   MAINTAINER Tim Daly <daly@axiom-developer.org>

>If you need to install anything you can use the RUN command
>which executes command line functions.
   # update the image to the latest repos
   RUN apt-get update

>You should specify the "-y" (yes) switch since there is no
>console interaction available
   # for X11 connections to hyperdoc
   RUN apt-get install -y libxpm-dev

>docker knows how to unpack several file formats automatically
>into the location of the second argument
   # untar axiom into the image at /usr/local
   ADD axiom.tgz /usr/local

>and it knows how to copy files to the second argument
   # put the  command in the path
   ADD axiom /usr/local/bin

   # make the command executable by everyone
   RUN chmod a+x /usr/local/bin/axiom







================================================================
10) run the docker build

   cd /root/docker
   docker build .

>docker build is going to use the files in the named directory (.)
>to modify the original image (ubuntu) to make a new image.


   

================================================================
12) commit the container with all of the changes (Note that
    doing anything with the container interatively will lose
    changes you don't commit)

   docker commit 12345abcde daly/axiom

>note that the image name "daly/axiom" should have your docker
>hub userid (daly) as the first element

>You can run the new image to test it. Note that any changes
>you make to the image will not be saved unless you do a commit.
>Commands that need I/O (such as bash) need the -i -t switches to
>give them stdio. To test your new image do:
>
>  docker run -i -t daly/axiom axiom