@@ -92,22 +92,16 @@ operations.
92
92
You can prevent the `yum` cache from ending up in an image layer by creating
93
93
your `RUN` statement as follows:
94
94
95
- ====
96
-
97
95
----
98
96
RUN yum -y install mypackage && yum -y install myotherpackage && yum clean all -y
99
97
----
100
- ====
101
98
102
99
Note that if you instead write:
103
100
104
- ====
105
-
106
101
----
107
102
RUN yum -y install mypackage
108
103
RUN yum -y install myotherpackage && yum clean all -y
109
104
----
110
- ====
111
105
112
106
Then the first `yum` invocation leaves extra files in that layer, and these
113
107
files cannot be removed when the `yum clean` operation is run later. The extra
@@ -138,29 +132,24 @@ For example, if you are working on a *_Dockerfile_* that contains an `ADD`
138
132
command to install a file you are iterating on, and a `RUN` command to `yum
139
133
install` a package, it is best to put the `ADD` command last:
140
134
141
- ====
142
135
143
136
----
144
137
FROM foo
145
138
RUN yum -y install mypackage && yum clean all -y
146
139
ADD myfile /test/myfile
147
140
----
148
- ====
149
141
150
142
This way each time you edit *_myfile_* and rerun `docker build`, the system reuses
151
143
the cached layer for the `yum` command and only generates the new layer for the
152
144
`ADD` operation.
153
145
154
146
If instead you wrote the *_Dockerfile_* as:
155
147
156
- ====
157
-
158
148
----
159
149
FROM foo
160
150
ADD myfile /test/myfile
161
151
RUN yum -y install mypackage && yum clean all -y
162
152
----
163
- ====
164
153
165
154
Then each time you changed *_myfile_* and reran `docker build`, the `ADD`
166
155
operation would invalidate the `RUN` layer cache, so the `yum` operation would
@@ -318,14 +307,15 @@ if ! whoami &> /dev/null; then
318
307
fi
319
308
----
320
309
321
- For a complete example of this, see
322
310
ifdef::openshift-origin[]
323
- link:https://github.com/RHsyseng/container-rhel-examples/blob/master/starter-arbitrary-uid/Dockerfile.centos7[this Dockerfile]
311
+ For a complete example of this, see
312
+ link:https://github.com/RHsyseng/container-rhel-examples/blob/master/starter-arbitrary-uid/Dockerfile.centos7[this Dockerfile].
324
313
endif::[]
325
314
ifdef::openshift-enterprise[]
326
- link:https://github.com/RHsyseng/container-rhel-examples/blob/master/starter-arbitrary-uid/Dockerfile[this Dockerfile]
315
+ For a complete example of this, see
316
+ link:https://github.com/RHsyseng/container-rhel-examples/blob/master/starter-arbitrary-uid/Dockerfile[this Dockerfile].
327
317
endif::[]
328
- .
318
+
329
319
330
320
Lastly, the final *USER* declaration in the `Dockerfile` should specify the user
331
321
ID (numeric value) and not the user name. This allows {product-title} to
0 commit comments