Skip to content

Commit 60ff1ed

Browse files
authored
Merge pull request openshift#9247 from adellape/arbdockerimg
Rename 'Other Container Images' topic, add security warning
2 parents 97ae21d + d0c5930 commit 60ff1ed

File tree

6 files changed

+120
-75
lines changed

6 files changed

+120
-75
lines changed

_topic_map.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -983,11 +983,6 @@ Topics:
983983
File: mongodb
984984
- Name: MariaDB
985985
File: mariadb
986-
- Name: Docker Images
987-
Dir: docker_images
988-
Topics:
989-
- Name: Overview
990-
File: index
991986
- Name: Other Images
992987
Dir: other_images
993988
Topics:
@@ -997,6 +992,8 @@ Topics:
997992
File: jenkins
998993
- Name: Jenkins Slaves
999994
File: jenkins_slaves
995+
- Name: Other Container Images
996+
File: other_container_images
1000997
- Name: xPaaS Middleware Images
1001998
Dir: xpaas_images
1002999
Distros: openshift-online,openshift-enterprise,openshift-dedicated

creating_images/guidelines.adoc

+47-25
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ consumable and easy to use on {product-title}.
2121
The following guidelines apply when creating a container image in general, and are
2222
independent of whether the images are used on {product-title}.
2323

24-
*Reuse Images*
24+
[discrete]
25+
===== Reuse Images
2526

2627
Wherever possible, we recommend that you base your image on an appropriate
2728
upstream image using the `FROM` statement. This ensures your image can easily
@@ -33,7 +34,8 @@ make it clear to users exactly which version of an image your image is based on.
3334
Using a tag other than `latest` ensures your image is not subjected to breaking
3435
changes that might go into the `latest` version of an upstream image.
3536

36-
*Maintain Compatibility Within Tags*
37+
[discrete]
38+
===== Maintain Compatibility Within Tags
3739

3840
When tagging your own images, we recommend that you try to maintain backwards
3941
compatibility within a tag. For example, if you provide an image named
@@ -49,7 +51,8 @@ new version at will, but not be inadvertently broken by the new incompatible
4951
image. Any downstream consumer using _foo:latest_ takes on the risk of any
5052
incompatible changes being introduced.
5153

52-
*Avoid Multiple Processes*
54+
[discrete]
55+
===== Avoid Multiple Processes
5356

5457
We recommend that you do not start multiple services, such as a database and
5558
*SSHD*, inside one container. This is not necessary because containers
@@ -63,7 +66,8 @@ less frequently and independently. Signal handling flows are also clearer with a
6366
single process as you do not need to manage routing signals to spawned
6467
processes.
6568

66-
*Use `exec` in Wrapper Scripts*
69+
[discrete]
70+
===== Use `exec` in Wrapper Scripts
6771

6872
See the "Always `exec` in Wrapper Scripts" section of the
6973
http://www.projectatomic.io/docs/docker-image-author-guidance[Project Atomic
@@ -82,7 +86,8 @@ init system (PID 1)"] blog article for a deep dive on PID 1 and *init*
8286
systems.
8387

8488

85-
*Clean Temporary Files*
89+
[discrete]
90+
===== Clean Temporary Files
8691

8792
All temporary files you create during the build process should be removed. This
8893
also includes any files added with the `ADD` command. For example, we strongly
@@ -119,7 +124,8 @@ them, where possible, so they do not end up written to a layer.
119124
In addition, performing multiple commands in a single `RUN` statement reduces
120125
the number of layers in your image, which improves download and extraction time.
121126

122-
*Place Instructions in the Proper Order*
127+
[discrete]
128+
===== Place Instructions in the Proper Order
123129

124130
Docker reads the *_Dockerfile_* and runs the instructions from top to
125131
bottom. Every instruction that is successfully executed creates a layer which
@@ -155,21 +161,24 @@ Then each time you changed *_myfile_* and reran `docker build`, the `ADD`
155161
operation would invalidate the `RUN` layer cache, so the `yum` operation would
156162
need to be rerun as well.
157163

158-
*Mark Important Ports*
164+
[discrete]
165+
===== Mark Important Ports
159166

160167
See the "Always `EXPOSE` Important Ports" section of the
161168
http://www.projectatomic.io/docs/docker-image-author-guidance[Project Atomic
162169
documentation] for more information.
163170

164-
*Set Environment Variables*
171+
[discrete]
172+
===== Set Environment Variables
165173

166174
It is good practice to set environment variables with the `ENV` instruction.
167175
One example is to set the version of your project. This makes it easy for people
168176
to find the version without looking at the *_Dockerfile_*. Another example is
169177
advertising a path on the system that could be used by another process, such as
170178
`*JAVA_HOME*`.
171179

172-
*Avoid Default Passwords*
180+
[discrete]
181+
===== Avoid Default Passwords
173182

174183
It is best to avoid setting default passwords. Many people will extend the image
175184
and forget to remove or change the default password. This can lead to security
@@ -183,7 +192,8 @@ message is displayed when the container is started. The message should inform
183192
the user of the value of the default password and explain how to change it, such
184193
as what environment variable to set.
185194

186-
*Avoid SSHD*
195+
[discrete]
196+
===== Avoid SSHD
187197

188198
It is best to avoid running *SSHD* in your image. You can use the `docker exec`
189199
command to access containers that are running on the local host. Alternatively,
@@ -195,7 +205,8 @@ command to access containers that are running on the {product-title} cluster.
195205
Installing and running *SSHD* in your image opens up additional vectors for
196206
attack and requirements for security patching.
197207

198-
*Use Volumes for Persistent Data*
208+
[discrete]
209+
===== Use Volumes for Persistent Data
199210

200211
Images should use a https://docs.docker.com/reference/builder/#volume[Docker
201212
volume] for persistent data. This way {product-title} mounts the network storage
@@ -227,7 +238,8 @@ NOTE: Even with persistent volumes, each instance of your image has its own
227238
volume, and the filesystem is not shared between instances. This means the
228239
volume cannot be used to share state in a cluster.
229240

230-
*External Guidelines*
241+
[discrete]
242+
===== External Guidelines
231243

232244
See the following references for other guidelines:
233245

@@ -239,15 +251,18 @@ See the following references for other guidelines:
239251
The following are guidelines that apply when creating container images specifically
240252
for use on {product-title}.
241253
ifdef::openshift-online[]
242-
*Privileges and Volume Builds*
254+
[discrete]
255+
===== Privileges and Volume Builds
243256

244257
Docker images cannot be built using the `VOLUME` directive in the `DOCKERFILE`.
245258
Images using a read/write file system need to use persistent volumes or
246259
`emptyDir` volumes instead of local storage. Instead of specifying a volume in
247260
the Dockerfile, specify a directory for local storage and mount either a
248261
persistent volume or `emptyDir` volume to that directory when deploying the pod.
249262
endif::[]
250-
*Enable Images for Source-To-Image (S2I)*
263+
264+
[discrete]
265+
===== Enable Images for Source-To-Image (S2I)
251266

252267
For images that are intended to run application code provided by a third party,
253268
such as a Ruby image designed to run Ruby code provided by a developer, you can
@@ -263,8 +278,9 @@ defines S2I scripts for building various versions of Python applications.
263278
For more details about how to write S2I scripts for your image, see the
264279
xref:s2i.adoc#creating-images-s2i[S2I Requirements] topic.
265280

281+
[discrete]
266282
[[use-uid]]
267-
*Support Arbitrary User IDs*
283+
===== Support Arbitrary User IDs
268284

269285
By default, {product-title} runs containers using an arbitrarily assigned user
270286
ID. This provides additional security against processes escaping the container
@@ -279,12 +295,10 @@ execute permissions.
279295
Adding the following to your Dockerfile sets the directory and file permissions
280296
to allow users in the root group to access them in the built image:
281297

282-
====
283298
----
284299
RUN chgrp -R 0 /some/directory && \
285300
chmod -R g=u /some/directory
286301
----
287-
====
288302

289303
Because the container user is always a member of the root group, the container
290304
user can read and write these files. The root group does not have any special
@@ -355,8 +369,9 @@ as any user].
355369
====
356370
endif::[]
357371

372+
[discrete]
358373
[[use-services]]
359-
*Use Services for Inter-image Communication*
374+
===== Use Services for Inter-image Communication
360375

361376
For cases where your image needs to communicate with a service provided by
362377
another image, such as a web front end image that needs to access a database
@@ -370,7 +385,8 @@ balancing for requests.
370385
For more information see https://kubernetes.io/docs/concepts/services-networking/service/[this documentation]. (NOTE to docs team: this link should really go to something in the openshift docs once we have it)
371386
////
372387

373-
*Provide Common Libraries*
388+
[discrete]
389+
===== Provide Common Libraries
374390

375391
For images that are intended to run application code provided by a third party,
376392
ensure that your image contains commonly used libraries for your platform. In
@@ -381,8 +397,9 @@ dependencies to be downloaded during application assembly time, speeding up
381397
application image builds. It also simplifies the work required by application
382398
developers to ensure all of their dependencies are met.
383399

400+
[discrete]
384401
[[use-env-vars]]
385-
*Use Environment Variables for Configuration*
402+
===== Use Environment Variables for Configuration
386403

387404
Users of your image should be able to configure it without having to create a
388405
downstream image based on your image. This means that the runtime configuration
@@ -430,7 +447,8 @@ in Docker containers:
430447
- Docker documentation - https://docs.docker.com/engine/admin/runmetrics/[Runtime Metrics]
431448
- Blog article - http://fabiokung.com/2014/03/13/memory-inside-linux-containers[Memory inside Linux containers]
432449

433-
*Set Image Metadata*
450+
[discrete]
451+
===== Set Image Metadata
434452

435453
Defining image metadata helps {product-title} better consume your container images,
436454
allowing {product-title} to create a better experience for developers using your
@@ -440,7 +458,8 @@ image, or offer suggestions on other images that may also be needed.
440458
See the xref:metadata.adoc#creating-images-metadata[Image Metadata] topic for more information on
441459
supported metadata and how to define them.
442460

443-
*Clustering*
461+
[discrete]
462+
===== Clustering
444463

445464
You must fully understand what it means to run multiple instances of your image.
446465
In the simplest case, the load balancing function of a service handles routing
@@ -453,7 +472,8 @@ Consider how your instances accomplish this communication when running in
453472
IP addresses change anytime the pod starts, stops, or is moved. Therefore, it is
454473
important for your clustering scheme to be dynamic.
455474

456-
*Logging*
475+
[discrete]
476+
===== Logging
457477

458478
It is best to send all logging to standard out. {product-title} collects
459479
standard out from containers and sends it to the centralized logging service
@@ -463,7 +483,8 @@ with an appropriate keyword, which makes it possible to filter the messages.
463483
If your image logs to a file, users must use manual operations to enter the
464484
running container and retrieve or view the log file.
465485

466-
*Liveness and Readiness Probes*
486+
[discrete]
487+
===== Liveness and Readiness Probes
467488

468489
Document example
469490
xref:../dev_guide/application_health.adoc#container-health-checks-using-probes[liveness
@@ -472,7 +493,8 @@ users to deploy your image with confidence that traffic will not be routed to
472493
the container until it is prepared to handle it, and that the container will be
473494
restarted if the process gets into an unhealthy state.
474495

475-
*Templates*
496+
[discrete]
497+
===== Templates
476498

477499
Consider providing an example xref:../dev_guide/templates.adoc#dev-guide-templates[template] with
478500
your image. A template will give users an easy way to quickly get your image

install_config/install/prerequisites.adoc

+21-18
Original file line numberDiff line numberDiff line change
@@ -248,32 +248,35 @@ Ansible installation.
248248
[[security-warning]]
249249
=== Security Warning
250250

251-
{product-title} runs
252-
xref:../../architecture/core_concepts/containers_and_images.adoc#containers[containers]
253-
on your hosts, and in some cases, such as build operations and the registry
254-
service, it does so using privileged containers. Furthermore, those containers
255-
access your host's Docker daemon and perform `docker build` and `docker push`
256-
operations. As such, you should be aware of the inherent security risks
257-
associated with performing `docker run` operations on arbitrary images as they
258-
effectively have root access. This is particularly relevant for Docker
259-
xref:../../architecture/core_concepts/builds_and_image_streams.adoc#builds[builds].
260-
261-
You can limit the exposure to harmful containers by assigning specific builds to
251+
// tag::container-image-security-warning[]
252+
{product-title} runs containers on hosts in the cluster, and in some cases, such
253+
as build operations and the registry service, it does so using privileged
254+
containers. Furthermore, those containers access the hosts' Docker daemon and
255+
perform `docker build` and `docker push` operations. As such, cluster
256+
administrators should be aware of the inherent security risks associated with
257+
performing `docker run` operations on arbitrary images as they effectively have
258+
root access. This is particularly relevant for `docker build` operations.
259+
260+
Exposure to harmful containers cam be limited by assigning specific builds to
262261
nodes so that any exposure is limited to those nodes. To do this, see the
263-
xref:../../dev_guide/builds/advanced_build_operations.adoc#dev-guide-assigning-builds-to-nodes[Assigning
264-
builds to specific nodes] section of the developer guide and
265-
xref:../../install_config/build_defaults_overrides.adoc#overview[Configuring
266-
global build defaults and overrides] section of the installation and
267-
configuration guide. You can also use
262+
xref:../../dev_guide/builds/advanced_build_operations.adoc#dev-guide-assigning-builds-to-nodes[Assigning Builds to Specific Nodes] section of the Developer Guide. For cluster
263+
administrators, see the
264+
xref:../../install_config/build_defaults_overrides.adoc#overview[Configuring Global Build Defaults and Overrides] section of the Installation and
265+
Configuration Guide.
266+
267+
You can also use
268268
xref:../../architecture/additional_concepts/authorization.adoc#security-context-constraints[security
269269
context constraints] to control the actions that a pod can perform and what it
270-
has the ability to access.
270+
has the ability to access. For instructions on how to enable images to run with
271+
*USER* in the Dockerfile, see
272+
xref:../../admin_guide/manage_scc.adoc#how-do-i[Managing Security Context
273+
Constraints] (requires a user with *cluster-admin* privileges).
271274

272275
For more information, see these articles:
273276

274277
- http://opensource.com/business/14/7/docker-security-selinux
275278
- https://docs.docker.com/engine/security/security/
276-
279+
// end::container-image-security-warning[]
277280

278281
[[envirornment-requirements]]
279282
== Environment Requirements

using_images/docker_images/index.adoc

-26
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[[using-images-other-container-images]]
2+
= Other Container Images
3+
{product-author}
4+
{product-version}
5+
:data-uri:
6+
:icons:
7+
:experimental:
8+
:toc: macro
9+
:toc-title:
10+
:prewrap!:
11+
12+
== Overview
13+
14+
If you want to use container images not found in the
15+
link:https://access.redhat.com/containers/[Red Hat Container Catalog], you can
16+
use other arbitrary container images in your {product-title} instance, for
17+
example those found on the https://registry.hub.docker.com/[Docker Hub].
18+
19+
For {product-title}-specific guidelines on running containers using an
20+
arbitrarily assigned user ID, see
21+
xref:../../creating_images/guidelines.adoc#use-uid[Support Arbitrary User IDs]
22+
in the Creating Images guide.
23+
24+
ifdef::openshift-enterprise[]
25+
[IMPORTANT]
26+
====
27+
For supportability details, see the Production Support Scope of Coverage as
28+
defined in the
29+
link:https://access.redhat.com/support/policy/updates/openshift/policies[{product-title} Support Policy].
30+
====
31+
endif::[]
32+
33+
ifdef::openshift-online[]
34+
[IMPORTANT]
35+
====
36+
{product-title} runs containers using an arbitrarily assigned user ID. This
37+
behavior provides additional security against processes escaping the container
38+
due to a container engine vulnerability and thereby achieving escalated
39+
permissions on the host node. Due to this restriction, images that run as root
40+
will not deploy as expected on {product-title}.
41+
====
42+
endif::[]
43+
44+
ifdef::openshift-enterprise,openshift-origin[]
45+
[[using-images-other-container-images-security-warning]]
46+
== Security Warning
47+
48+
include::install_config/install/prerequisites.adoc[tag=container-image-security-warning]
49+
endif::[]

0 commit comments

Comments
 (0)