TMAegisBeta
Aturan lainnya untuk docker

Docker

TMA-DOCKER-5.9

Ensure that only needed ports are open on the container

SedangLevel 1Tinjauan manualdocker

Deskripsi

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.

Cara pemeriksaan

Metode audit: Tinjauan manual

Rekomendasi ini tidak dapat diperiksa secara otomatis. Pemindaian akan menampilkannya beserta petunjuk ini saat Anda memberikan opsi --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.

Cara perbaikan

Metode perbaikan: Panduan atau patch infrastruktur

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

Properti

Sistem operasi
Apa saja
Tag
dockermanual
Referensi
CIS Docker Benchmark v1.9.0 - 5.9 Ensure that only needed ports are open on the container