TMAegisBêta
Plus de règles pour docker

Docker

TMA-DOCKER-5.9

Ensure that only needed ports are open on the container

MoyenneNiveau 1Revue manuelledocker

Description

The Dockerfile for a container image defines the ports which are opened by default on a container instance. The list of ports are relevant to the application you are running within the container and should only be open if they are needed. A container can be run with only the ports defined in the Dockerfile for its image or can alternatively be arbitrarily passed run time parameters to open a list of ports. Reported as a manual review item: the audit needs a site-specific judgement.

Méthode de vérification

Méthode d'audit: Revue manuelle

Cette recommandation ne peut pas être vérifiée automatiquement. Une analyse la liste avec ces instructions lorsque vous passez --include-manual.

You should list all the running instances of containers and their associated port mappings by executing the command below: docker ps --quiet | xargs docker inspect --format '{{ .Id }}: Ports={{ .NetworkSettings.Ports }}' You should then review the list and ensure that all the ports mapped are in fact genuinely required by each container.

Méthode de correction

Méthode de correction: Recommandation ou correctif d'infrastructure

You should ensure that the Dockerfile for each container image only exposes needed ports. You can also completely ignore the list of ports defined in the Dockerfile by NOT using -P (UPPERCASE) or the --publish-all flag when starting the container. Instead, use the -p (lowercase) or --publish flag to explicitly define the ports that you need for a particular container instance. For example: docker run --interactive --tty --publish 5000 --publish 5001 --publish 5002 centos /bin/bash

Propriétés

Systèmes d'exploitation
Tous
Étiquettes
dockermanual
Référence
CIS Docker Benchmark v1.9.0 - 5.9 Ensure that only needed ports are open on the container