Différences
Ci-dessous, les différences entre deux révisions de la page.
elearning:workbooks:centos:6:sec:l111 [2021/02/28 14:19] – created admin | elearning:workbooks:centos:6:sec:l111 [2021/02/28 16:52] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 5: | Ligne 5: | ||
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======LRF411 - Démarrer avec Docker====== | + | ======LRF411 - Gestion de la Sécurité de Docker====== |
=====Contenu du Module===== | =====Contenu du Module===== | ||
- | * **LRF411 - Démarrer avec Docker** | + | * **LRF411 - Gestion de la Sécurité de Docker** |
* Contenu du Module | * Contenu du Module | ||
- | * Présentation | + | * LAB #1 - Création d'un Utilisateur |
- | * LAB #1 - Travailler avec Docker | + | * LAB #2 - Le Script docker-bench-security.sh |
- | * 1.1 - Installer docker | + | * LAB #3 - Sécurisation de la Configuration de l' |
- | * 1.2 - Démarrer un Conteneur | + | * 3.1 - [WARN] |
- | * 1.3 - Consulter la Liste des Conteneurs et Images | + | * 3.2 - [WARN] |
- | * 1.4 - Rechercher une Image dans un Dépôt | + | * LAB #4 - Sécurisation de la Configuration du daemon Docker |
- | * 1.5 - Supprimer un Conteneur d'une Image | + | * 4.1 - [WARN] 2.1 - Ensure network traffic is restricted between containers on the default bridge |
- | * 1.6 - Créer une Image à partir d'un Conteneur Modifié | + | * 4.2 - [WARN] 2.8 - Enable user namespace support |
- | * 1.7 - Supprimer une Image | + | * 4.3 - [WARN] 2.11 - Ensure that authorization for Docker client commands is enabled |
- | * 1.8 - Créer un Conteneur avec un Nom Spécifique | + | * 4.4 - [WARN] 2.12 - Ensure centralized and remote logging is configured |
- | * 1.9 - Exécuter une Commande dans un Conteneur | + | * 4.5 - [WARN] 2.14 - Ensure Userland Proxy is Disabled |
- | * 1.10 - Injecter des Variables d' | + | * 4.6 - [WARN] 2.17 - Ensure containers are restricted from acquiring new privileges |
- | * 1.11 - Modifier le Nom d' | + | * 4.7 - Le Fichier / |
- | * 1.12 - Mapper des Ports d'un Conteneur | + | * LAB #5 - Sécurisation des Images et les Fichiers de Construction |
- | * 1.13 - Démarrer un Conteneur en mode Détaché | + | * 5.1 - [WARN] 4.1 - Ensure a user for the container has been created |
- | * 1.14 - Accéder aux Services d'un Conteneur de l' | + | * 5.2 - [WARN] 4.5 - Ensure Content trust for Docker is Enabled |
- | * 1.15 - Arrêter et Démarrer un Conteneur | + | * 5.3 - [WARN] 4.6 - Ensure that HEALTHCHECK instructions have been added to container images |
- | * 1.16 - Utiliser des Signaux avec un Conteneur | + | * LAB #6 - Sécurisation du Container Runtime |
- | * 1.17 - Forcer la Suppression d'un Conteneur en cours d'Exécution | + | * 6.1 - [WARN] 5.1 - Ensure AppArmor Profile is Enabled |
- | * 1.18 - Utilisation Simple d'un Volume | + | * 6.2 - [WARN] 5.2 - Ensure SELinux security options are set, if applicable |
- | * 1.19 - Télécharger une image sans créer un conteneur | + | * 6.3 - [WARN] 5.10 - Ensure memory usage for container is limited |
- | * 1.20 - S' | + | * 6.4 - [WARN] 5.11 - Ensure CPU priority is set appropriately on the container |
- | * 1.21 - Installer un logiciel dans le conteneur | + | * 6.5 - [WARN] 5.12 - Ensure the container' |
- | * 1.22 - Utilisation de la commande docker | + | * 6.6 - [WARN] 5.14 - Ensure |
- | * 1.23 - Se connecter au serveur du conteneur de l' | + | * 6.7 - [WARN] 5.25 - Ensure the container is restricted from acquiring additional privileges |
+ | * 6.8 - [WARN] 5.26 - Ensure container health is checked at runtime | ||
+ | * 6.9 - [WARN] 5.28 - Ensure PIDs cgroup limit is used | ||
+ | * LAB #7 - Sécurisation des Images avec Docker Content Trust | ||
+ | * 7.1 - DOCKER_CONTENT_TRUST | ||
+ | * 7.2 - DCT et la commande docker pull | ||
+ | * L' | ||
+ | * 7.3 - DCT et la commande docker | ||
+ | * 7.4 - DCT et la commande docker build | ||
+ | * Créer un deuxième Repositry | ||
+ | * Supprimer une Signature | ||
- | =====Présentation | + | =====LAB #1 - Création d'un Utilisateur |
- | Docker | + | Au contraire des solutions classiques de gestion de machines virtuelles où l' |
- | Une **image** est un paquet exécutable contenant tout ce qu'il est necessaire afin d' | + | < |
+ | root@debian9: | ||
+ | docker: | ||
+ | root@debian9: | ||
+ | root@debian9: | ||
+ | déconnexion | ||
+ | trainee@manager: | ||
+ | Got permission denied while trying to connect to the Docker daemon socket at unix:/// | ||
+ | trainee@manager: | ||
+ | trainee@manager: | ||
+ | CONTAINER ID IMAGE | ||
+ | d02c6115724c | ||
+ | trainee@manager: | ||
+ | alpine1 | ||
+ | trainee@manager: | ||
+ | a214e2df0499c97e8da25a6c9ea751ac75344c9bcd7d238f8cb8d5c777510ab9 | ||
+ | trainee@manager:~$ docker ps -a | ||
+ | CONTAINER ID IMAGE | ||
+ | a214e2df0499 | ||
+ | </ | ||
- | * le code | + | =====LAB #2 - Le Script docker-bench-security.sh===== |
- | * un runtime | + | |
- | * des bibliothèques, | + | |
- | * des variables d' | + | |
- | * des fichiers de configuration | + | |
- | Un **conteneur** est une instance | + | Le **Center for Internet Security (CIS)** est une organisation indépendante à but non-lucratif qui publie des best practices dans de nombreux domaines |
- | Les conteneurs exécutent des applications nativement | + | Le guide est divisé |
- | Docker existe en deux versions **Docker-CE** (Docker | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
- | =====LAB #1 - Travailler | + | Ce guide est à utiliser |
- | ====1.1 - Installer docker==== | + | Clonez |
- | + | ||
- | Docker n'est pas dans le dépôts de Debian. Afin de l' | + | |
< | < | ||
- | root@debian9:~# apt-get update | + | trainee@manager:~$ su - |
- | ... | + | Mot de passe : fenestros |
- | root@debian9: | + | root@debian9: |
- | Reading package lists... Done | + | Clonage dans ' |
- | Building dependency tree | + | remote: Enumerating objects: 18, done. |
- | Reading state information... Done | + | remote: Counting objects: 100% (18/18), done. |
- | ca-certificates is already the newest version. | + | remote: Compressing objects: 100% (16/16), done. |
- | ca-certificates set to manually installed. | + | remote: Total 1921 (delta 5), reused 6 (delta |
- | gnupg2 is already the newest version. | + | Réception d' |
- | gnupg2 set to manually installed. | + | Résolution des deltas: 100% (1339/1339), fait. |
- | The following extra packages will be installed: | + | |
- | libcurl3 python3-dbus python3-software-properties unattended-upgrades | + | |
- | Suggested packages: | + | |
- | | + | |
- | The following NEW packages will be installed: | + | |
- | apt-transport-https curl libcurl3 python3-dbus python3-software-properties | + | |
- | software-properties-common unattended-upgrades | + | |
- | 0 upgraded, 7 newly installed, 0 to remove and 1 not upgraded. | + | |
- | Need to get 960 kB of archives. | + | |
- | After this operation, 2,344 kB of additional disk space will be used. | + | |
- | Do you want to continue? [Y/n] | + | |
</ | </ | ||
- | Téléchargez la clef GPG officielle de docker | + | Exécutez maintenant le script **Docker Benchmark Security** |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | OK | + | root@debian9:~/docker-bench-security# |
- | </ | + | # ------------------------------------------------------------------------------ |
+ | # Docker Bench for Security v1.3.5 | ||
+ | # | ||
+ | # Docker, Inc. (c) 2015- | ||
+ | # | ||
+ | # Checks for dozens of common best-practices around deploying Docker containers in production. | ||
+ | # Inspired by the CIS Docker Benchmark v1.2.0. | ||
+ | # ------------------------------------------------------------------------------ | ||
+ | |||
+ | Initializing vendredi 8 novembre 2019, 12:12:03 (UTC+0100) | ||
- | Vérifiez que l'ID de la clef est **9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88** : | ||
- | < | + | [INFO] 1 - Host Configuration |
- | root@debian9: | + | |
- | / | + | [INFO] 1.1 - General Configuration |
- | -------------------- | + | [NOTE] 1.1.1 |
- | pub | + | [INFO] 1.1.2 - Ensure Docker is up to date |
- | Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 | + | [INFO] |
- | uid | + | [INFO] |
- | sub | + | |
+ | [INFO] 1.2 - Linux Hosts Specific Configuration | ||
+ | [WARN] 1.2.1 - Ensure a separate partition for containers has been created | ||
... | ... | ||
</ | </ | ||
- | Ajoutez | + | Ce script sert à automatiser |
- | < | + | * **[PASS]** : Concerne les points qui n'ont pas besoin d' |
- | root@debian9:~# add-apt-repository " | + | * **[WARN]** |
- | </ | + | * **[INFO]** : Concerne les points qui doivent être passés en revue selon les besoins de votre configuration, |
+ | * **[NOTE]** : Vous informe d'un **best practice**. | ||
- | <WRAP center round important> | + | =====LAB #3 - Sécurisation de la Configuration |
- | **Important** | + | |
- | </ | + | |
- | Installez maintenant le paquet **docker-ce** : | + | Lors de l' |
- | <code> | + | <file> |
- | root@debian9: | + | |
... | ... | ||
- | root@debian9: | + | [INFO] 1 - Host Configuration |
- | Reading package lists... Done | + | |
- | Building dependency tree | + | |
- | Reading state information... Done | + | |
- | The following extra packages will be installed: | + | |
- | aufs-tools cgroupfs-mount git git-man libapparmor1 liberror-perl | + | |
- | libnih-dbus1 libnih1 makedev mountall plymouth rsync | + | |
- | Suggested packages: | + | |
- | git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk | + | |
- | gitweb git-arch git-cvs git-mediawiki git-svn plymouth-themes | + | |
- | The following NEW packages will be installed: | + | |
- | aufs-tools cgroupfs-mount docker-ce git git-man libapparmor1 liberror-perl | + | |
- | libnih-dbus1 libnih1 makedev mountall plymouth rsync | + | |
- | 0 upgraded, 13 newly installed, 0 to remove and 99 not upgraded. | + | |
- | Need to get 26.5 MB of archives. | + | |
- | After this operation, 123 MB of additional disk space will be used. | + | |
- | Do you want to continue? | + | |
- | </ | + | |
- | Dernièrement, vérifiez la version de Docker | + | [INFO] 1.1 - General Configuration |
+ | [NOTE] 1.1.1 - Ensure the container host has been Hardened | ||
+ | [INFO] 1.1.2 - Ensure Docker is up to date | ||
+ | [INFO] | ||
+ | [INFO] | ||
- | < | + | [INFO] 1.2 - Linux Hosts Specific Configuration |
- | root@debian9:~# docker | + | [WARN] 1.2.1 - Ensure a separate partition for containers has been created |
- | Client: | + | [INFO] 1.2.2 - Ensure only trusted users are allowed to control Docker daemon |
- | Version: | + | [INFO] |
- | API version: | + | [WARN] 1.2.3 - Ensure auditing is configured for the Docker daemon |
- | Go version: | + | [WARN] 1.2.4 - Ensure auditing is configured for Docker files and directories - /var/lib/docker |
- | Git commit: | + | [WARN] 1.2.5 - Ensure auditing is configured for Docker |
- | Built: | + | [WARN] 1.2.6 - Ensure auditing is configured for Docker files and directories - docker.service |
- | OS/Arch: linux/amd64 | + | [WARN] |
- | Experimental: | + | [WARN] 1.2.8 - Ensure auditing is configured for Docker files and directories - / |
+ | [INFO] 1.2.9 - Ensure auditing is configured for Docker files and directories - / | ||
+ | [INFO] | ||
+ | [INFO] 1.2.10 - Ensure auditing is configured for Docker files and directories - / | ||
+ | [INFO] | ||
+ | [WARN] 1.2.11 | ||
+ | [INFO] 1.2.12 | ||
+ | [INFO] | ||
+ | ... | ||
+ | </ | ||
- | Server: Docker Engine - Community | + | Les problèmes de sécurité qu'il convient à résoudre sont indiqués par les annotations **[WARN]**. |
- | | + | |
- | Version: | + | |
- | API version: | + | |
- | Go version: | + | |
- | Git commit: | + | |
- | Built: | + | |
- | OS/ | + | |
- | Experimental: | + | |
- | | + | |
- | Version: | + | |
- | GitCommit: | + | |
- | | + | |
- | Version: | + | |
- | GitCommit: | + | |
- | | + | |
- | Version: | + | |
- | GitCommit: | + | |
- | </ | + | |
- | <WRAP center round important> | + | ====3.1 |
- | **Important** | + | |
- | </ | + | |
- | Re-démarrez la machine virtuelle avant de poursuivre : | + | Par défaut, tous les fichiers |
- | <code> | + | ====3.2 - [WARN] 1.2.3 - Ensure auditing is configured for the Docker daemon==== |
- | root@debian9: | + | |
- | </code> | + | <file> |
+ | [WARN] 1.2.4 | ||
+ | [WARN] 1.2.5 - Ensure auditing is configured for Docker files and directories - / | ||
+ | [WARN] 1.2.6 - Ensure auditing is configured for Docker files and directories - docker.service | ||
+ | [WARN] 1.2.7 - Ensure auditing is configured for Docker files and directories - docker.socket | ||
+ | [WARN] 1.2.8 - Ensure auditing is configured for Docker files and directories - / | ||
+ | [WARN] 1.2.11 | ||
+ | </file> | ||
- | ====1.2 - Démarrer un Conteneur==== | + | Ces avertissements sont présents parce que **auditd** n'est pas installé et parce qu'il n'y a pas de règles spécifiques au daemon Docker et ses répertoires et fichiers associés. |
- | Démarrez un conteneur de l' | + | Pour installer auditd, utilisez **apt-get** : |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | Unable to find image 'hello-world: | + | </code> |
- | latest: Pulling from library/hello-world | + | |
- | 1b930d010525: | + | |
- | Digest: sha256: | + | |
- | Status: Downloaded newer image for hello-world: | + | |
- | Hello from Docker! | + | Modifiez ensuite le fichier **/ |
- | This message shows that your installation appears to be working correctly. | + | |
- | To generate this message, Docker took the following steps: | + | < |
- | 1. The Docker client contacted the Docker daemon. | + | root@debian9:~/ |
- | 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. | + | root@debian9: |
- | (amd64) | + | ## First rule - delete all |
- | 3. The Docker daemon created a new container from that image which runs the | + | -D |
- | | + | |
- | 4. The Docker daemon streamed that output to the Docker client, which sent it | + | |
- | to your terminal. | + | |
- | To try something more ambitious, you can run an Ubuntu container with: | + | ## Increase the buffers to survive stress events. |
- | $ docker run -it ubuntu bash | + | ## Make this bigger for busy systems |
+ | -b 8192 | ||
- | Share images, automate workflows, and more with a free Docker ID: | + | ## This determine how long to wait in burst of events |
- | https:// | + | --backlog_wait_time 0 |
- | For more examples and ideas, visit: | + | ## Set failure mode to syslog |
- | https://docs.docker.com/get-started/ | + | -f 1 |
+ | |||
+ | ##Docker | ||
+ | -w /usr/bin/docker -p wa | ||
+ | -w / | ||
+ | -w /etc/docker -p wa | ||
+ | -w / | ||
+ | -w / | ||
+ | -w /etc/ | ||
+ | -w /etc/ | ||
+ | -w / | ||
+ | -w / | ||
+ | -w / | ||
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
- | **Important** | + | **Important** |
</ | </ | ||
- | Démarrez un conteneur de l' | + | Re-démarrez ensuite auditd |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | Unable to find image ' | + | |
- | latest: Pulling from library/ | + | |
- | 898c46f3b1a1: | + | |
- | 63366dfa0a50: | + | |
- | 041d4cd74a92: | + | |
- | 6e1bee0f8701: | + | |
- | Digest: sha256: | + | |
- | Status: Downloaded newer image for ubuntu: | + | |
- | root@3a3f9bda6cbd:/ | + | |
- | bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | |
- | root@3a3f9bda6cbd:/# | + | |
- | DISTRIB_ID=Ubuntu | + | |
- | DISTRIB_RELEASE=18.04 | + | |
- | DISTRIB_CODENAME=bionic | + | |
- | DISTRIB_DESCRIPTION=" | + | |
</ | </ | ||
- | <WRAP center round important> | + | Vérifiez ensuite la prise en charge des règles : |
- | **Important** - Notez que dans ce cas le conteneur est lancé | + | |
+ | < | ||
+ | root@debian9: | ||
+ | ## This file is automatically generated from / | ||
+ | -D | ||
+ | -b 8192 | ||
+ | -f 1 | ||
+ | --backlog_wait_time 0 | ||
+ | -w / | ||
+ | -w / | ||
+ | -w /etc/docker -p wa | ||
+ | -w / | ||
+ | -w / | ||
+ | -w / | ||
+ | -w / | ||
+ | -w / | ||
+ | -w / | ||
+ | -w / | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important | ||
+ | **Important** - Pour plus d' | ||
</ | </ | ||
- | Consulter la liste des paquets installés dans le conteneur ubuntu | + | Ré-exécutez |
< | < | ||
- | root@835001339e79:/# dpkg -l | + | root@debian9:~/docker-bench-security# ./docker-bench-security.sh |
- | Desired=Unknown/ | + | ... |
- | | Status=Not/ | + | [PASS] |
- | |/ Err? | + | [PASS] |
- | ||/ Name | + | [PASS] |
- | +++-====================================-=======================-=======================-============================================================================= | + | [PASS] |
- | ii adduser | + | [PASS] 1.2.8 - Ensure auditing is configured |
- | ii apt 1.6.8 | + | ... |
- | ii base-files | + | [PASS] |
- | ii base-passwd | + | ... |
- | ii bash | + | |
- | ii bsdutils | + | |
- | ii bzip2 1.0.6-8.1 | + | |
- | ii coreutils | + | |
- | ii dash | + | |
- | ii debconf | + | |
- | ii debianutils | + | |
- | ii diffutils | + | |
- | ii dpkg | + | |
- | ii e2fsprogs | + | |
- | ii fdisk 2.31.1-0.4ubuntu3.3 | + | |
- | ii findutils | + | |
- | ii gcc-8-base: | + | |
- | ii gpgv | + | |
- | ii grep | + | |
- | ii gzip 1.6-5ubuntu1 | + | |
- | ii hostname | + | |
- | ii init-system-helpers | + | |
- | ii libacl1: | + | |
- | ii libapt-pkg5.0: | + | |
- | ii libattr1: | + | |
- | ii libaudit-common | + | |
- | ii libaudit1: | + | |
- | ii libblkid1: | + | |
- | ii libbz2-1.0: | + | |
- | ii libc-bin | + | |
- | ii libc6: | + | |
- | ii libcap-ng0: | + | |
- | ii libcom-err2: | + | |
- | ii libdb5.3: | + | |
- | ii libdebconfclient0: | + | |
- | ii libext2fs2: | + | |
- | ii libfdisk1: | + | |
- | ii libffi6: | + | |
- | ii libgcc1: | + | |
- | ii libgcrypt20: | + | |
- | ii libgmp10: | + | |
- | ii libgnutls30: | + | |
- | ii libgpg-error0: | + | |
- | ii libhogweed4: | + | |
- | ii libidn2-0: | + | |
- | ii liblz4-1: | + | |
- | ii liblzma5: | + | |
- | ii libmount1: | + | |
- | ii libncurses5: | + | |
- | ii libncursesw5: | + | |
- | ii libnettle6: | + | |
- | ii libp11-kit0: | + | |
- | ii libpam-modules: | + | |
- | ii libpam-modules-bin | + | |
- | ii libpam-runtime | + | |
- | ii libpam0g: | + | |
- | ii libpcre3: | + | |
- | ii libprocps6: | + | |
- | ii libseccomp2: | + | |
- | ii libselinux1: | + | |
- | ii libsemanage-common | + | |
- | ii libsemanage1: | + | |
- | ii libsepol1: | + | |
- | ii libsmartcols1: | + | |
- | ii libss2: | + | |
- | ii libstdc++6: | + | |
- | ii libsystemd0: | + | |
- | ii libtasn1-6: | + | |
- | ii libtinfo5: | + | |
- | ii libudev1: | + | |
- | ii libunistring2: | + | |
- | ii libuuid1: | + | |
- | ii libzstd1: | + | |
- | ii login 1: | + | |
- | ii lsb-base | + | |
- | ii mawk | + | |
- | ii mount 2.31.1-0.4ubuntu3.3 | + | |
- | ii ncurses-base | + | |
- | ii ncurses-bin | + | |
- | ii passwd | + | |
- | ii perl-base | + | |
- | ii procps | + | |
- | ii sed 4.4-2 | + | |
- | ii sensible-utils | + | |
- | ii sysvinit-utils | + | |
- | ii tar 1.29b-2ubuntu0.1 | + | |
- | ii ubuntu-keyring | + | |
- | ii util-linux | + | |
- | ii zlib1g: | + | |
- | root@835001339e79:/# | + | |
- | exit | + | |
- | root@debian9: | + | |
</ | </ | ||
- | Les options | + | =====LAB #4 - Sécurisation |
- | < | + | Exécutez de nouveau le script **docker-bench-security.sh**. Vous devez obtenir un résultat similaire à ceci en ce qui concerne la sécurité de la configuration du daemon Docker : |
- | root@debian9: | + | |
- | Usage: | + | < |
+ | ... | ||
+ | [INFO] 2 - Docker daemon configuration | ||
+ | [WARN] 2.1 - Ensure network traffic is restricted between containers on the default bridge | ||
+ | [PASS] 2.2 - Ensure the logging level is set to ' | ||
+ | [PASS] 2.3 - Ensure Docker is allowed to make changes to iptables | ||
+ | [PASS] 2.4 - Ensure insecure registries are not used | ||
+ | [PASS] 2.5 - Ensure aufs storage driver is not used | ||
+ | [INFO] 2.6 - Ensure TLS authentication for Docker daemon is configured | ||
+ | [INFO] | ||
+ | [INFO] 2.7 - Ensure the default ulimit is configured appropriately | ||
+ | [INFO] | ||
+ | [WARN] 2.8 - Enable user namespace support | ||
+ | [PASS] 2.9 - Ensure the default cgroup usage has been confirmed | ||
+ | [PASS] 2.10 - Ensure base device size is not changed until needed | ||
+ | [WARN] 2.11 - Ensure that authorization for Docker client commands is enabled | ||
+ | [WARN] 2.12 - Ensure centralized and remote logging is configured | ||
+ | [PASS] 2.13 - Ensure live restore is Enabled (Incompatible with swarm mode) | ||
+ | [WARN] 2.14 - Ensure Userland Proxy is Disabled | ||
+ | [PASS] 2.15 - Ensure that a daemon-wide custom seccomp profile is applied if appropriate | ||
+ | [PASS] 2.16 - Ensure that experimental features are not implemented in production | ||
+ | [WARN] 2.17 - Ensure containers are restricted from acquiring new privileges | ||
+ | ... | ||
+ | </ | ||
- | Run a command in a new container | + | Les problèmes de sécurité qu'il convient à résoudre sont indiqués par les annotations **[WARN]**. |
- | Options: | + | ====4.1 |
- | | + | |
- | -a, --attach list Attach to STDIN, STDOUT or STDERR | + | |
- | --blkio-weight uint16 | + | |
- | --blkio-weight-device list Block IO weight (relative device weight) (default | + | |
- | --cap-add list Add Linux capabilities | + | |
- | --cap-drop list Drop Linux capabilities | + | |
- | --cgroup-parent string | + | |
- | --cidfile string | + | |
- | --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period | + | |
- | --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota | + | |
- | --cpu-rt-period int Limit CPU real-time period in microseconds | + | |
- | --cpu-rt-runtime int Limit CPU real-time runtime in microseconds | + | |
- | -c, --cpu-shares int CPU shares (relative weight) | + | |
- | --cpus decimal | + | |
- | --cpuset-cpus string | + | |
- | --cpuset-mems string | + | |
- | -d, --detach | + | |
- | --detach-keys string | + | |
- | --device list Add a host device to the container | + | |
- | --device-cgroup-rule list Add a rule to the cgroup allowed devices list | + | |
- | --device-read-bps list Limit read rate (bytes per second) from a device (default []) | + | |
- | --device-read-iops list Limit read rate (IO per second) from a device (default []) | + | |
- | --device-write-bps list Limit write rate (bytes per second) to a device (default []) | + | |
- | --device-write-iops list Limit write rate (IO per second) to a device (default []) | + | |
- | --disable-content-trust | + | |
- | --dns list Set custom DNS servers | + | |
- | --dns-option list Set DNS options | + | |
- | --dns-search list Set custom DNS search domains | + | |
- | --entrypoint string | + | |
- | -e, --env list Set environment variables | + | |
- | --env-file list Read in a file of environment variables | + | |
- | --expose list Expose a port or a range of ports | + | |
- | --group-add list Add additional groups to join | + | |
- | --health-cmd string | + | |
- | --health-interval duration | + | |
- | --health-retries int | + | |
- | --health-start-period duration | + | |
- | --health-timeout duration | + | |
- | --help | + | |
- | -h, --hostname string | + | |
- | --init | + | |
- | -i, --interactive | + | |
- | --ip string | + | |
- | --ip6 string | + | |
- | --ipc string | + | |
- | --isolation string | + | |
- | --kernel-memory bytes Kernel memory limit | + | |
- | -l, --label list Set meta data on a container | + | |
- | --label-file list Read in a line delimited file of labels | + | |
- | --link list Add link to another container | + | |
- | --link-local-ip list | + | |
- | --log-driver string | + | |
- | --log-opt list Log driver options | + | |
- | --mac-address string | + | |
- | -m, --memory bytes | + | |
- | --memory-reservation bytes | + | |
- | --memory-swap bytes Swap limit equal to memory plus swap: ' | + | |
- | --memory-swappiness int Tune container memory swappiness (0 to 100) (default | + | |
- | --mount mount Attach a filesystem mount to the container | + | |
- | --name string | + | |
- | --network string | + | |
- | --network-alias list Add network-scoped alias for the container | + | |
- | --no-healthcheck | + | |
- | --oom-kill-disable | + | |
- | --oom-score-adj int Tune host's OOM preferences (-1000 to 1000) | + | |
- | --pid string | + | |
- | --pids-limit int Tune container pids limit (set -1 for unlimited) | + | |
- | --privileged | + | |
- | -p, --publish list | + | |
- | -P, --publish-all | + | |
- | --read-only | + | |
- | --restart string | + | |
- | --rm | + | |
- | --runtime string | + | |
- | --security-opt list Security Options | + | |
- | --shm-size bytes Size of /dev/shm | + | |
- | --sig-proxy | + | |
- | --stop-signal string | + | |
- | --stop-timeout int | + | |
- | --storage-opt list | + | |
- | --sysctl map | + | |
- | --tmpfs list Mount a tmpfs directory | + | |
- | -t, --tty Allocate a pseudo-TTY | + | |
- | --ulimit ulimit | + | |
- | -u, --user string | + | |
- | --userns string | + | |
- | --uts string | + | |
- | -v, --volume list Bind mount a volume | + | |
- | --volume-driver string | + | |
- | --volumes-from list Mount volumes from the specified container(s) | + | |
- | -w, --workdir string | + | |
- | </ | + | |
- | ====1.3 - Consulter | + | Par défaut Docker permet un trafic réseau sans restrictions entre des conteneurs sur le même hôte. Il est cependant possible de modifier |
- | Pour consulter tous les conteneurs, utilisez la commande | + | Pour plus d' |
- | < | + | ====4.2 |
- | root@debian9: | + | |
- | CONTAINER ID IMAGE | + | |
- | 3a3f9bda6cbd | + | |
- | 26ef17bd115d | + | |
- | </ | + | |
- | <WRAP center round important> | + | Cet avertissement nous indique que l' |
- | **Important** - Notez que chaque | + | |
- | </ | + | |
- | Pour consulter la liste des images, utilisez la commande | + | Pour plus d' |
- | < | + | ====4.3 - [WARN] 2.11 - Ensure that authorization for Docker client commands is enabled==== |
- | root@debian9: | + | |
- | REPOSITORY | + | |
- | ubuntu | + | |
- | hello-world | + | |
- | </ | + | |
- | <WRAP center round important> | + | Par défaut, Docker permet un accès sans restrictions aux daemon Docker. Il est possible de restreindre l' |
- | **Important** - Notez que chaque image est référencée par son IMAGE ID. | + | |
- | </ | + | |
- | ====1.4 - Rechercher une Image dans un Dépôt==== | + | Pour plus d' |
- | Pour rechercher une image docker dans le dépôt par défaut, utilisez la commande **docker search** : | + | ====4.4 - [WARN] 2.12 - Ensure centralized and remote logging is configured==== |
- | < | + | Cet avertissement indique que la configuration de rsyslog ne permet pas l' |
- | root@debian9: | + | |
- | NAME DESCRIPTION | + | |
- | centos | + | |
- | ansible/ | + | |
- | jdeathe/ | + | |
- | consol/ | + | |
- | imagine10255/ | + | |
- | centos/ | + | |
- | tutum/ | + | |
- | gluster/ | + | |
- | openshift/ | + | |
- | centos/ | + | |
- | centos/ | + | |
- | kinogmt/ | + | |
- | centos/ | + | |
- | centos/ | + | |
- | openshift/ | + | |
- | pivotaldata/ | + | |
- | openshift/ | + | |
- | </ | + | |
- | <WRAP center round important> | + | Pour plus d' |
- | **Important** - Notez que chaque image est référencée par la colonne NAME. Le NAME est sous le format **repository/mainteneur/nom** sauf dans le cas où il s'agit de l' | + | |
- | </ | + | |
- | ====1.5 - Supprimer un Conteneur d'une Image==== | + | ====4.5 - [WARN] 2.14 - Ensure Userland Proxy is Disabled==== |
- | Pour supprimer | + | Il existe deux méthodes pour qu'un conteneur |
- | < | + | * le mode **Hairpin NAT**, |
- | root@debian9: | + | * **Userland Proxy**. |
- | CONTAINER ID IMAGE | + | |
- | 3a3f9bda6cbd | + | |
- | 26ef17bd115d | + | |
- | root@debian9: | + | |
- | wizardly_buck | + | |
- | root@debian9: | + | |
- | CONTAINER ID IMAGE | + | |
- | 26ef17bd115d | + | |
- | root@debian9: | + | |
- | REPOSITORY | + | |
- | ubuntu | + | |
- | hello-world | + | |
- | </ | + | |
- | <WRAP center round important> | + | Il est préférable |
- | **Important** - Notez que dans le cas de l' | + | |
- | </ | + | |
- | ====1.6 -Créer une Image à partir | + | Pour plus d'informations, |
- | Modifier un conteneur d'une image : | + | ====4.6 - [WARN] 2.17 - Ensure containers are restricted from acquiring new privileges==== |
- | < | + | Par défaut un conteneur peut obtenir une escalade de privilèges en utilisant les binaires setuid ou setgid. Pour interdire ceci il faut fixer la valeur de **no-new-privileges** à **true**. |
- | root@debian9: | + | |
- | root@54b0dae2f3a9:/# | + | |
- | bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | |
- | root@54b0dae2f3a9:/# | + | |
- | root@54b0dae2f3a9:/# | + | |
- | bin boot dev etc lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | |
- | root@54b0dae2f3a9:/# | + | |
- | exit | + | |
- | root@debian9: | + | |
- | </ | + | |
- | <WRAP center round important> | + | Pour plus d' |
- | **Important** - Notez ici la suppression du répertoire **home** dans le conteneur **54b0dae2f3a9**. | + | |
- | </WRAP> | + | ====4.7 - Le Fichier |
- | Consultez la différence entre le conteneur et l' | + | Créez |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | CONTAINER ID IMAGE | + | root@debian9: |
- | 54b0dae2f3a9 | + | { |
- | 26ef17bd115d | + | " |
- | root@debian9: | + | " |
- | C /root | + | " |
- | A /root/.bash_history | + | " |
- | D /home | + | " |
+ | " | ||
+ | } | ||
</ | </ | ||
- | <WRAP center round important> | + | Notez ici que **live-restore** est fixé à **true**. Ceci permet aux conteneurs de continuer à fonctionner même quand le daemon Docker ne fonctionne pas. Ceci est utile pendant la mise-à-jour de Docker. |
- | **Important** - La sortie de la commande | + | |
- | </ | + | |
- | Créez un autre conteneur à partir de l' | + | Re-démarrez le service Docker |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | root@92f0d4bb7967:/# | + | |
- | bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | |
- | root@92f0d4bb7967:/# | + | |
- | exit | + | |
- | root@debian9: | + | |
</ | </ | ||
- | <WRAP center round important> | + | Vérifiez la présence |
- | **Important** - Dans ce nouveau conteneur, le répertoire **/home** est présent compte tenu du fait qu'il a été généré à partir | + | |
- | </ | + | |
- | + | ||
- | Créez maintenant l' | + | |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | CONTAINER ID IMAGE | + | uid=116(dockremap) gid=121(dockremap) groupes=121(dockremap) |
- | 92f0d4bb7967 | + | |
- | 54b0dae2f3a9 | + | |
- | 26ef17bd115d | + | |
- | root@debian9: | + | |
- | sha256: | + | |
- | root@debian9: | + | |
- | REPOSITORY | + | |
- | ubuntu_1 | + | |
- | ubuntu | + | |
- | hello-world | + | |
</ | </ | ||
- | ====1.7 | + | Ré-exécutez le script |
- | + | ||
- | Créez maintenant un conteneur à partir de la nouvelle image **ubuntu_1** : | + | |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | root@904215fb79b4:/# ls | + | root@debian9:~/docker-bench-security# ./ |
- | bin boot dev etc lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | ... |
- | root@904215fb79b4:/# | + | [PASS] 2.1 - Ensure network traffic is restricted between containers on the default bridge |
- | exit | + | ... |
- | root@debian9: | + | [PASS] 2.8 - Enable user namespace support |
+ | ... | ||
+ | [WARN] 2.11 - Ensure that authorization for Docker client commands is enabled | ||
+ | [PASS] 2.12 - Ensure centralized and remote logging is configured | ||
+ | ... | ||
+ | [PASS] 2.14 - Ensure Userland Proxy is Disabled | ||
+ | ... | ||
+ | [PASS] 2.17 - Ensure containers are restricted from acquiring new privileges | ||
+ | ... | ||
</ | </ | ||
- | <WRAP center round important> | + | Pour plus d' |
- | **Important** - Notez l' | + | |
- | </ | + | |
- | Essayez | + | =====LAB #5 - Sécurisation des Images et les Fichiers |
+ | |||
+ | Créez le conteneur mysql : | ||
< | < | ||
- | root@debian9: | + | root@debian9: |
- | Error response | + | Unable to find image ' |
- | root@debian9: | + | latest: Pulling |
- | CONTAINER ID IMAGE | + | 80369df48736: Pull complete |
- | 904215fb79b4 | + | e8f52315cb10: Pull complete |
- | 92f0d4bb7967 | + | cf2189b391fc: |
- | 54b0dae2f3a9 | + | cc98f645c682: |
- | 26ef17bd115d | + | 27a27ac83f74: |
+ | fa1f04453414: | ||
+ | d45bf7d22d33: | ||
+ | 3dbac26e409c: | ||
+ | 9017140fb8c1: | ||
+ | b76dda2673ae: | ||
+ | bea9eb46d12a: | ||
+ | e1f050a38d0f: | ||
+ | Digest: sha256: | ||
+ | Status: Downloaded newer image for mysql: | ||
+ | 54606c03c52c5e3ec0328029d69b869d4b285fb433015576dedc8b8dd4ad0494 | ||
+ | root@debian9: | ||
+ | CONTAINER ID IMAGE | ||
+ | 54606c03c52c | ||
</ | </ | ||
- | <WRAP center round important> | + | Exécutez |
- | **Important** - Notez qu'il n'est pas possible | + | |
- | </ | + | |
- | + | ||
- | Supprimez donc le conteneur **priceless_swirles** ainsi que l' | + | |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | priceless_swirles | + | ... |
- | root@debian9: | + | [INFO] 4 - Container Images and Build File |
- | CONTAINER ID IMAGE | + | [WARN] 4.1 - Ensure |
- | 92f0d4bb7967 | + | [WARN] |
- | 54b0dae2f3a9 | + | [NOTE] |
- | 26ef17bd115d | + | [NOTE] 4.3 - Ensure that unnecessary packages are not installed in the container |
- | root@debian9: | + | [NOTE] 4.4 - Ensure images are scanned and rebuilt to include security patches |
- | Untagged: ubuntu_1:latest | + | [WARN] 4.5 |
- | Deleted: sha256:2ba8e0ec5e38332c8ab15c4b33fd140a9c74d72231d05a6965c40a39fbb44584 | + | [WARN] 4.6 - Ensure that HEALTHCHECK instructions have been added to container images |
- | Deleted: sha256:308e9761a8fc84661e46eff564b0bbca12b458e71bdf77bf4abbb59b21efdbbe | + | [WARN] |
- | root@debian9: | + | [WARN] |
- | REPOSITORY | + | [INFO] 4.7 - Ensure update instructions are not use alone in the Dockerfile |
- | ubuntu | + | [INFO] |
- | hello-world | + | [NOTE] 4.8 - Ensure setuid and setgid permissions are removed |
+ | [PASS] 4.9 - Ensure that COPY is used instead of ADD in Dockerfiles | ||
+ | [NOTE] | ||
+ | [NOTE] 4.11 | ||
+ | ... | ||
</ | </ | ||
- | Pour pouvoir supprimer tous les conteneurs, listez-les par leur **Container ID** : | + | ====5.1 - [WARN] 4.1 - Ensure a user for the container has been created==== |
+ | |||
+ | Les processus dans le conteneur **root-nginx** tourne sous l'UID de root. Ceci est l' | ||
+ | |||
+ | Pour plus d' | ||
+ | |||
+ | ====5.2 | ||
+ | |||
+ | Cette ligne indique que le support de Content trust n'a pas été activé. Content trust permet de s' | ||
+ | |||
+ | Pour activer le Content trust, il faut positionner la valeur de la variable **DOCKER_CONTENT_TRUST** à **1** : | ||
< | < | ||
- | root@debian9: | + | root@debian9: |
- | 92f0d4bb7967 | + | DOCKER_CONTENT_TRUST=1 |
- | 54b0dae2f3a9 | + | root@debian9: |
- | 26ef17bd115d | + | |
</ | </ | ||
- | Supprimer toutes les conteneurs | + | Re-démarrez la machine virtuelle **Manager** et démarrez le conteneur **mysql** |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | 92f0d4bb7967 | + | mysql |
- | 54b0dae2f3a9 | + | root@debian9: |
- | 26ef17bd115d | + | CONTAINER ID IMAGE |
- | root@debian9: | + | 54606c03c52c |
- | root@debian9: | + | |
</ | </ | ||
- | Pour supprimer un conteneur dès la fin de son exécution, utilisez l' | + | Exécutez |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | root@d123b0112fc2:/# ls | + | ... |
- | bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | [INFO] 4 - Container Images and Build File |
- | root@d123b0112fc2:/# exit | + | [WARN] 4.1 - Ensure a user for the container has been created |
- | exit | + | [WARN] |
- | root@debian9:~# docker ps -aq | + | [NOTE] 4.2 - Ensure that containers use only trusted base images |
- | root@debian9:~# | + | [NOTE] 4.3 - Ensure that unnecessary packages are not installed in the container |
+ | [NOTE] 4.4 - Ensure images are scanned and rebuilt to include security patches | ||
+ | [PASS] 4.5 - Ensure Content trust for Docker is Enabled | ||
+ | [WARN] 4.6 - Ensure that HEALTHCHECK instructions have been added to container images | ||
+ | [WARN] | ||
+ | [WARN] | ||
+ | [INFO] 4.7 | ||
+ | [INFO] | ||
+ | [NOTE] 4.8 - Ensure setuid and setgid permissions are removed | ||
+ | [PASS] 4.9 - Ensure that COPY is used instead of ADD in Dockerfiles | ||
+ | [NOTE] 4.10 - Ensure secrets are not stored in Dockerfiles | ||
+ | [NOTE] 4.11 - Ensure only verified packages are installed | ||
+ | ... | ||
</ | </ | ||
- | ====1.8 - Créer un Conteneur avec un Nom Spécifique==== | + | Pour plus d' |
- | Créez maintenant un conteneur avec un nom spécifique : | + | ====5.3 - [WARN] 4.6 - Ensure that HEALTHCHECK instructions have been added to container images==== |
- | < | + | Quand une image est construite il est possible d'y mettre un **HEALTHCHECK** dont le statut peut être vérifié par Docker afin de relancer le conteneur si nécessaire. |
- | root@debian9: | + | |
- | root@04b5ab87539a:/# | + | |
- | bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | |
- | root@04b5ab87539a:/# | + | |
- | exit | + | |
- | root@debian9: | + | |
- | CONTAINER ID IMAGE | + | |
- | 04b5ab87539a | + | |
- | </ | + | |
- | Pour obtenir de l' | + | Pour mettre en place un HEALTHCHECK, il conviendrait, |
- | <code> | + | <file> |
- | root@debian9: | + | HEALTHCHECK |
- | [ | + | </file> |
- | { | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | 0, | + | |
- | 0 | + | |
- | ], | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | "/ | + | |
- | "/ | + | |
- | "/ | + | |
- | "/ | + | |
- | "/ | + | |
- | "/ | + | |
- | "/ | + | |
- | "/ | + | |
- | "/ | + | |
- | "/ | + | |
- | ], | + | |
- | " | + | |
- | "/ | + | |
- | "/ | + | |
- | "/ | + | |
- | "/ | + | |
- | "/ | + | |
- | ] | + | |
- | }, | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | " | + | |
- | }, | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | ], | + | |
- | " | + | |
- | "/ | + | |
- | ], | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | ] | + | |
- | </code> | + | |
- | ====1.9 - Exécuter | + | Ce test permet de vérifier que le conteneur peut atteindre l'URL indiqué tous les 20 secondes et produit |
- | Pour exécuter une commande spécifique dans un conteneur, passez la commande | + | Pour plus d' |
+ | |||
+ | =====LAB #6 - Sécurisation du Container Runtime===== | ||
+ | |||
+ | Exécutez de nouveau le script **docker-bench-security.sh**, | ||
< | < | ||
- | root@debian9: | + | root@debian9: |
- | PATH=/ | + | ... |
- | HOSTNAME=77bb110031aa | + | [INFO] 5 - Container Runtime |
- | HOME=/root | + | [WARN] 5.1 - Ensure that, if applicable, an AppArmor Profile is enabled |
- | root@debian9:~# | + | [WARN] |
+ | [WARN] 5.2 - Ensure that, if applicable, SELinux security options are set | ||
+ | [WARN] | ||
+ | [PASS] 5.3 - Ensure Linux Kernel Capabilities are restricted within containers | ||
+ | [PASS] 5.4 - Ensure that privileged containers are not used | ||
+ | [PASS] 5.5 - Ensure sensitive host system directories are not mounted on containers | ||
+ | [PASS] 5.6 - Ensure sshd is not run within containers | ||
+ | [PASS] 5.7 | ||
+ | [NOTE] 5.8 | ||
+ | [PASS] 5.9 - Ensure the host's network namespace is not shared | ||
+ | [WARN] 5.10 - Ensure that the memory usage for containers is limited | ||
+ | [WARN] | ||
+ | [WARN] 5.11 - Ensure CPU priority is set appropriately on the container | ||
+ | [WARN] | ||
+ | [WARN] 5.12 - Ensure that the container' | ||
+ | [WARN] | ||
+ | [PASS] 5.13 - Ensure that incoming container traffic is bound to a specific host interface | ||
+ | [WARN] 5.14 - Ensure that the ' | ||
+ | [WARN] | ||
+ | [PASS] 5.15 - Ensure the host's process namespace is not shared | ||
+ | [PASS] 5.16 - Ensure the host's IPC namespace is not shared | ||
+ | [PASS] 5.17 - Ensure that host devices are not directly exposed to containers | ||
+ | [INFO] 5.18 - Ensure that the default ulimit is overwritten at runtime if needed | ||
+ | [INFO] | ||
+ | [PASS] 5.19 - Ensure mount propagation mode is not set to shared | ||
+ | [PASS] 5.20 - Ensure the host's UTS namespace is not shared | ||
+ | [PASS] 5.21 - Ensure the default seccomp profile is not Disabled | ||
+ | [NOTE] 5.22 - Ensure docker exec commands are not used with privileged option | ||
+ | [NOTE] 5.23 - Ensure that docker exec commands are not used with the user=root option | ||
+ | [PASS] 5.24 - Ensure that cgroup usage is confirmed | ||
+ | [WARN] 5.25 - Ensure that the container is restricted from acquiring additional privileges | ||
+ | [WARN] | ||
+ | [WARN] 5.26 - Ensure that container health is checked at runtime | ||
+ | [WARN] | ||
+ | [INFO] 5.27 - Ensure that Docker commands always make use of the latest version of their image | ||
+ | [WARN] 5.28 - Ensure that the PIDs cgroup limit is used | ||
+ | [WARN] | ||
+ | [INFO] 5.29 - Ensure that Docker' | ||
+ | [INFO] | ||
+ | [PASS] 5.30 - Ensure that the host's user namespaces are not shared | ||
+ | [PASS] 5.31 - Ensure that the Docker socket is not mounted inside any containers | ||
+ | ... | ||
</ | </ | ||
- | ====1.10 - Injecter des Variables d'Environnement dans un Conteneur==== | + | Les problèmes de sécurité qu'il convient à résoudre sont indiqués par les annotations **[WARN]**. |
- | Pour injecter une ou des variables | + | ====6.1 - [WARN] 5.1 - Ensure AppArmor Profile is Enabled==== |
+ | |||
+ | Cet avertissement est présent parce que le conteneur n' | ||
+ | |||
+ | Pour plus d'informations, | ||
+ | |||
+ | ====6.2 - [WARN] 5.2 - Ensure SELinux security options are set, if applicable==== | ||
+ | |||
+ | Cet avertissement est présent parce que le conteneur | ||
+ | |||
+ | Pour plus d' | ||
+ | |||
+ | ====6.3 - [WARN] 5.10 - Ensure memory usage for container is limited==== | ||
+ | |||
+ | Cet avertissement est du au fait que les conteneurs ont automatiquement accès à la totalité de la RAM de l' | ||
< | < | ||
- | root@debian9: | + | root@debian9: |
- | root@debian9: | + | b04b2a6f0dd93da21a8b7640afc319406e42868a141f90936dbcf52ab5bffb0d |
- | EDITOR=vim | + | root@debian9: |
- | HOSTNAME=ubuntudocker | + | CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O |
+ | b04b2a6f0dd9 | ||
+ | ^C | ||
</ | </ | ||
+ | |||
+ | Supprimez le conteneur et re-créez le avec une limite de mémoire : | ||
< | < | ||
- | root@debian9: | + | root@debian9: |
- | PATH=/ | + | CONTAINER ID IMAGE |
- | HOSTNAME=ubuntudocker | + | b04b2a6f0dd9 |
- | EDITOR=vim | + | 5b31fe1e13bc |
- | HOME=/root | + | 7788c67c3b69 |
- | root@debian9: | + | root@debian9:~# docker rm -f b0 |
+ | b0 | ||
+ | root@debian9: | ||
+ | 095472e5096a57277230ff94822d9bd0ad479ad26a33cbf83ec381cdb02910e1 | ||
+ | root@debian9: | ||
+ | CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O | ||
+ | 095472e5096a | ||
+ | ^C | ||
</ | </ | ||
- | ====1.11 - Modifier le Nom d'Hôte d'un Conteneur==== | + | Pour plus d'informations, |
- | Pour modifier le nom d' | + | ====6.4 |
- | < | + | Cet avertissement est du au fait que les conteneurs ont automatiquement accès à tous les CPU de l' |
- | root@debian9: | + | |
- | root@ubuntudocker:/# | + | |
- | ubuntudocker | + | |
- | root@ubuntudocker:/# | + | |
- | exit | + | |
- | root@debian9: | + | |
- | </ | + | |
- | ====1.12 | + | La valeur de cpu-shares est relative à la valeur par défaut de **1024**. Un valeur de 512 permet au conteneur |
- | Démarrer | + | Pour plus d' |
+ | |||
+ | ====6.5 - [WARN] 5.12 - Ensure the container' | ||
+ | |||
+ | Afin de minimiser le risque de compromettre | ||
+ | |||
+ | Créez | ||
< | < | ||
- | root@debian9: | + | root@debian9: |
- | Unable to find image ' | + | |
- | latest: Pulling from library/ | + | |
- | 27833a3ba0a5: | + | |
- | e83729dd399a: | + | |
- | ebc6a67df66d: | + | |
- | Digest: sha256: | + | |
- | Status: Downloaded newer image for nginx: | + | |
- | ^Croot@debian9: | + | |
</ | </ | ||
- | Notez que c' | + | La Commande **docker container diff** indique les différences apportées au conteneur par rapport à l'image dont il est issu : |
< | < | ||
- | ^Croot@debian9:~# docker | + | root@debian9:~/docker-bench-security# |
- | CONTAINER ID IMAGE | + | A / |
- | 4f157e179134 | + | C /run |
- | 04b5ab87539a | + | C / |
+ | A / | ||
+ | A / | ||
+ | A / | ||
+ | A / | ||
+ | A /run/mysqld/mysqld.pid | ||
</ | </ | ||
- | ====1.13 - Démarrer un Conteneur en mode Détaché==== | + | <WRAP center round important 60%> |
+ | **Important** : Notez que la sortie indique les changements apportés au conteneur. | ||
+ | </ | ||
- | Démarrez maintenant | + | Arrêtez et supprimez |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | aabb064d4b0ade1f19216b6174631fa32a2053f6aa9d59bd724ea90ce534b004 | + | mysql |
- | root@debian9: | + | root@debian9: |
- | CONTAINER ID IMAGE | + | mysql |
- | aabb064d4b0a | + | |
- | 4f157e179134 | + | |
- | 04b5ab87539a | + | |
</ | </ | ||
- | ====1.14 - Accèder aux Services d'un Conteneur de l' | + | Lancez |
- | Installez | + | < |
+ | root@debian9: | ||
+ | 7788c67c3b692515f63f4659a8f40af397bfbde97485e2e40c500c16b158045b | ||
+ | root@debian9: | ||
+ | CONTAINER ID IMAGE | ||
+ | 7788c67c3b69 | ||
+ | </ | ||
+ | |||
+ | Créez | ||
< | < | ||
- | root@debian9: | + | root@debian9: |
- | Lecture des listes de paquets... Fait | + | touch: cannot touch '/write_a_file' |
- | Construction de l' | + | |
- | Lecture des informations d' | + | |
- | The following additional packages will be installed: | + | |
- | lynx-common | + | |
- | Les NOUVEAUX paquets suivants seront installés : | + | |
- | lynx lynx-common | + | |
- | 0 mis à jour, 2 nouvellement installés, 0 à enlever et 94 non mis à jour. | + | |
- | Il est nécessaire de prendre 1 730 ko dans les archives. | + | |
- | Après cette opération, 5 590 ko d'espace disque supplémentaires seront utilisés. | + | |
- | Souhaitez-vous continuer ? [O/n] o | + | |
- | Réception de:1 http:// | + | |
- | Réception de:2 http:// | + | |
- | 1 730 ko réceptionnés en 6s (283 ko/s) | + | |
- | Sélection du paquet lynx-common précédemment désélectionné. | + | |
- | (Lecture de la base de données... 113082 fichiers et répertoires déjà installés.) | + | |
- | Préparation du dépaquetage de .../ | + | |
- | Dépaquetage de lynx-common (2.8.9dev11-1) ... | + | |
- | Sélection du paquet lynx précédemment désélectionné. | + | |
- | Préparation du dépaquetage de .../ | + | |
- | Dépaquetage de lynx (2.8.9dev11-1) ... | + | |
- | Traitement des actions différées (« triggers ») pour mime-support (3.60) ... | + | |
- | Traitement des actions différées (« triggers ») pour man-db (2.7.6.1-2) ... | + | |
- | Paramétrage de lynx-common (2.8.9dev11-1) ... | + | |
- | Paramétrage de lynx (2.8.9dev11-1) ... | + | |
- | update-alternatives: | + | |
</ | </ | ||
- | Vérifiez que nginx répond aux requetes | + | <WRAP center round important 60%> |
+ | **Important** : Notez l' | ||
+ | </ | ||
+ | |||
+ | Exécutez la commande **docker container diff** | ||
< | < | ||
- | root@debian9: | + | root@debian9: |
- | Welcome to nginx! | + | root@debian9:~/docker-bench-security# |
+ | </ | ||
- | If you see this page, the nginx web server is successfully installed | + | <WRAP center round important 60%> |
- | and working. Further configuration is required. | + | **Important** : Notez que la commande ne retourne aucune sortie. En effet le conteneur étant en lecture seule, aucun changement ne peut intervenir. |
+ | </ | ||
- | For online documentation and support please refer to [1]nginx.org. | + | ====6.6 - [WARN] 5.14 - Ensure ' |
- | | + | |
- | Thank you for using nginx. | + | Cet avertissement concerne la politique de re-démarrage du conteneur. La politique **on-failure[: |
- | Références | + | # docker container run -d --name mysql --read-only --restart on-failure: |
- | 1. http://nginx.org/ | + | Pour plus d' |
- | 2. http://nginx.com/ | + | |
- | </code> | + | |
- | ====1.15 - Arrêter et Démarrer un Conteneur==== | + | ====6.7 - [WARN] 5.25 - Ensure the container is restricted from acquiring additional privileges==== |
- | Arrêtez | + | Pour complémenter la configuration précédemment mise en place, il convient de lancer |
- | < | + | |
- | root@debian9: | + | |
- | CONTAINER ID IMAGE | + | |
- | aabb064d4b0a | + | |
- | 4f157e179134 | + | |
- | 04b5ab87539a | + | |
- | root@debian9: | + | |
- | aabb | + | |
- | root@debian9: | + | |
- | CONTAINER ID IMAGE | + | |
- | aabb064d4b0a | + | |
- | 4f157e179134 | + | |
- | 04b5ab87539a | + | |
- | </code> | + | |
- | Démarrez de nouveau le conteneur de nginx : | + | Pour plus d' |
- | < | + | ====6.8 |
- | root@debian9: | + | |
- | aabb | + | |
- | root@debian9: | + | |
- | CONTAINER ID IMAGE | + | |
- | aabb064d4b0a | + | |
- | 4f157e179134 | + | |
- | 04b5ab87539a | + | |
- | </ | + | |
- | ====1.16 - Utiliser des Signaux avec un Conteneur==== | + | Voir l' |
- | Utilisez | + | ====6.9 - [WARN] 5.28 - Ensure PIDs cgroup limit is used==== |
+ | |||
+ | Sans l' | ||
< | < | ||
- | root@debian9: | + | root@debian9: |
- | aabb | + | |
- | root@debian9: | + | |
- | CONTAINER ID IMAGE | + | |
- | aabb064d4b0a | + | |
- | 4f157e179134 | + | |
- | 04b5ab87539a | + | |
</ | </ | ||
- | Redémarrez un conteneur en cours : | + | L' |
< | < | ||
- | root@debian9: | ||
- | aabb | ||
root@debian9: | root@debian9: | ||
- | CONTAINER ID IMAGE | + | CONTAINER ID IMAGE |
- | aabb064d4b0a | + | 05b11e44e595 |
- | 4f157e179134 | + | ... |
- | 04b5ab87539a | + | root@debian9: |
- | root@debian9: | + | 05 |
- | aabb | + | root@debian9: |
- | root@debian9: | + | environment: |
- | CONTAINER ID IMAGE | + | environment: |
- | aabb064d4b0a | + | environment: |
- | 4f157e179134 | + | environment: |
- | 04b5ab87539a | + | environment: |
+ | environment: | ||
+ | ^C | ||
</ | </ | ||
- | ====1.17 - Forcer la Suppression | + | Pour plus d'informations, |
- | Supprimez | + | Supprimez |
< | < | ||
- | root@debian9: | ||
- | Error response from daemon: You cannot remove a running container aabb064d4b0ade1f19216b6174631fa32a2053f6aa9d59bd724ea90ce534b004. Stop the container before attempting removal or force remove | ||
root@debian9: | root@debian9: | ||
- | CONTAINER ID IMAGE | + | CONTAINER ID IMAGE |
- | aabb064d4b0a | + | 095472e5096a |
- | 4f157e179134 | + | 5b31fe1e13bc |
- | 04b5ab87539a | + | 7788c67c3b69 |
- | root@debian9: | + | root@debian9: |
- | aabb | + | 095 |
+ | root@debian9: | ||
+ | 5b31fe1e13bc | ||
+ | 7788c67c3b69 | ||
+ | 095472e5096a | ||
root@debian9: | root@debian9: | ||
- | CONTAINER ID IMAGE | + | CONTAINER ID IMAGE |
- | 4f157e179134 | + | |
- | 04b5ab87539a | + | |
</ | </ | ||
- | ===1.18 | + | Re-créez |
- | + | ||
- | Créez | + | |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | root@debian9: | + | root@debian9: |
- | root@debian9:~# cat index.html | + | df54974ebc11fe357f6e8e9b0f8499aee2658af435e32a45058a1e49fcd3dc24 |
- | < | + | root@debian9: |
- | < | + | CONTAINER ID IMAGE |
- | < | + | df54974ebc11 |
- | </body> | + | |
- | </html> | + | |
- | root@debian9: | + | |
</ | </ | ||
- | Indiquez au conteneur que son répertoire **/ | + | Exécutez de nouveau |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | c080793965de8a6a60db212d7e4d96de84b55352c224c054dced75b409e39bf2 | + | ... |
- | root@debian9:~# lynx --dump http:// | + | [INFO] 5 - Container Runtime |
- | | + | [WARN] 5.1 - Ensure that, if applicable, an AppArmor Profile is enabled |
+ | [WARN] | ||
+ | [PASS] 5.2 | ||
+ | [PASS] 5.3 - Ensure Linux Kernel Capabilities are restricted within containers | ||
+ | [PASS] 5.4 - Ensure that privileged containers are not used | ||
+ | [PASS] 5.5 - Ensure sensitive host system directories are not mounted on containers | ||
+ | [PASS] 5.6 - Ensure sshd is not run within containers | ||
+ | [PASS] 5.7 - Ensure privileged ports are not mapped within containers | ||
+ | [NOTE] 5.8 - Ensure that only needed ports are open on the container | ||
+ | [PASS] 5.9 - Ensure the host's network namespace is not shared | ||
+ | [PASS] 5.10 - Ensure that the memory usage for containers is limited | ||
+ | [PASS] 5.11 - Ensure CPU priority is set appropriately on the container | ||
+ | [PASS] 5.12 - Ensure that the container' | ||
+ | [PASS] 5.13 - Ensure that incoming container traffic is bound to a specific host interface | ||
+ | [PASS] 5.14 - Ensure that the ' | ||
+ | [PASS] 5.15 - Ensure the host's process namespace is not shared | ||
+ | [PASS] 5.16 - Ensure the host's IPC namespace is not shared | ||
+ | [PASS] 5.17 - Ensure that host devices are not directly exposed to containers | ||
+ | [INFO] 5.18 - Ensure that the default ulimit is overwritten at runtime if needed | ||
+ | [INFO] | ||
+ | [PASS] 5.19 - Ensure mount propagation mode is not set to shared | ||
+ | [PASS] 5.20 - Ensure the host's UTS namespace is not shared | ||
+ | [PASS] 5.21 - Ensure the default seccomp profile is not Disabled | ||
+ | [NOTE] 5.22 - Ensure docker exec commands are not used with privileged option | ||
+ | [NOTE] 5.23 - Ensure that docker exec commands are not used with the user=root option | ||
+ | [PASS] 5.24 - Ensure that cgroup usage is confirmed | ||
+ | [PASS] 5.25 - Ensure that the container is restricted from acquiring additional privileges | ||
+ | [WARN] 5.26 - Ensure that container health is checked at runtime | ||
+ | [WARN] | ||
+ | [INFO] 5.27 | ||
+ | [PASS] 5.28 | ||
+ | [INFO] 5.29 - Ensure that Docker' | ||
+ | [INFO] | ||
+ | [PASS] 5.30 - Ensure that the host's user namespaces are not shared | ||
+ | [PASS] 5.31 - Ensure that the Docker socket is not mounted inside any containers | ||
+ | ... | ||
+ | </ | ||
+ | =====LAB #7 - Sécurisation des Images avec Docker Content Trust===== | ||
- | root@debian9: | + | **Docker Content Trust (DCT)** a été introduit avec Docker Engine 1.8 et Docker CS Engine 1.9.0. DCT permet la vérification de l' |
- | </ | + | |
- | <WRAP center round important> | + | DCT est utilisé par le **Docker Hub Registry** mais peut aussi être mis en place dans des Registry privés, notamment grâce à la mise en place du **[[https:// |
- | **Important** - Notez ici l' | + | |
- | </ | + | |
- | ====1.19 - Télécharger une image sans créer un conteneur==== | + | DCT est basé sur l' |
- | Téléchargez l'image de centos sans créer un conteneur | + | Pour plus d'information concernant DCT, consultez cette **[[https:// |
- | < | + | ====7.1 - DOCKER_CONTENT_TRUST==== |
- | root@debian9: | + | |
- | Using default tag: latest | + | |
- | latest: Pulling from library/ | + | |
- | 8ba884070f61: | + | |
- | Digest: sha256: | + | |
- | Status: Downloaded newer image for centos: | + | |
- | </ | + | |
- | Vérifiez le contenu | + | Pour utiliser **Docker Content Trust (DCT)**, il convient |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | [root@86252a3f00f4 /]# cat / | + | 1 |
- | CentOS Linux release 7.6.1810 (Core) | + | |
- | [root@86252a3f00f4 /]# rpm -qa | more | + | |
- | bind-license-9.9.4-73.el7_6.noarch | + | |
- | bash-4.2.46-31.el7.x86_64 | + | |
- | glibc-common-2.17-260.el7_6.3.x86_64 | + | |
- | nss-softokn-freebl-3.36.0-5.el7_5.x86_64 | + | |
- | filesystem-3.2-25.el7.x86_64 | + | |
- | glibc-2.17-260.el7_6.3.x86_64 | + | |
- | nspr-4.19.0-1.el7_5.x86_64 | + | |
- | popt-1.13-16.el7.x86_64 | + | |
- | libcom_err-1.42.9-13.el7.x86_64 | + | |
- | libcap-2.22-9.el7.x86_64 | + | |
- | libstdc++-4.8.5-36.el7.x86_64 | + | |
- | info-5.1-5.el7.x86_64 | + | |
- | gawk-4.0.2-4.el7_3.1.x86_64 | + | |
- | libselinux-2.5-14.1.el7.x86_64 | + | |
- | grep-2.20-3.el7.x86_64 | + | |
- | keyutils-libs-1.5.8-3.el7.x86_64 | + | |
- | libverto-0.2.5-4.el7.x86_64 | + | |
- | p11-kit-trust-0.23.5-3.el7.x86_64 | + | |
- | openssl-libs-1.0.2k-16.el7.x86_64 | + | |
- | krb5-libs-1.15.1-37.el7_6.x86_64 | + | |
- | xz-libs-5.2.2-1.el7.x86_64 | + | |
- | libdb-5.3.21-24.el7.x86_64 | + | |
- | libgpg-error-1.12-3.el7.x86_64 | + | |
- | libgcrypt-1.5.3-14.el7.x86_64 | + | |
- | lua-5.1.4-15.el7.x86_64 | + | |
- | libuuid-2.23.2-59.el7.x86_64 | + | |
- | libmount-2.23.2-59.el7.x86_64 | + | |
- | shared-mime-info-1.8-4.el7.x86_64 | + | |
- | gzip-1.5-10.el7.x86_64 | + | |
- | findutils-4.5.11-6.el7.x86_64 | + | |
- | diffutils-3.3-4.el7.x86_64 | + | |
- | expat-2.1.0-10.el7_3.x86_64 | + | |
- | audit-libs-2.8.4-4.el7.x86_64 | + | |
- | pam-1.1.8-22.el7.x86_64 | + | |
- | nss-softokn-3.36.0-5.el7_5.x86_64 | + | |
- | nss-3.36.0-7.1.el7_6.x86_64 | + | |
- | libassuan-2.1.0-3.el7.x86_64 | + | |
- | nss-tools-3.36.0-7.1.el7_6.x86_64 | + | |
- | gobject-introspection-1.56.1-1.el7.x86_64 | + | |
- | --More-- | + | |
</ | </ | ||
- | ====1.20 - S' | + | Dans le cas contraire, il faut fixer la valeur de la variable à 1 : |
- | + | ||
- | Arretez le conteneur. Démarrez le conteneur puis rattachez-vous au conteneur | + | |
< | < | ||
- | [root@86252a3f00f4 /]# exit | + | root@debian9: |
- | exit | + | root@debian9: |
- | root@debian9: | + | 1 |
- | CONTAINER ID IMAGE | + | |
- | 86252a3f00f4 | + | |
- | c080793965de | + | |
- | 4f157e179134 | + | |
- | 04b5ab87539a | + | |
- | root@debian9: | + | |
- | 8625 | + | |
- | root@debian9: | + | |
- | [root@86252a3f00f4 /]# ls | + | |
- | anaconda-post.log | + | |
- | [root@86252a3f00f4 /]# | + | |
</ | </ | ||
- | ====1.21 - Installer un logiciel dans le conteneur=== | + | ====7.2 - DCT et la commande docker pull==== |
- | Créez le fichier **/ | + | Afin d' |
< | < | ||
- | [root@86252a3f00f4 /]# vi /etc/yum.repos.d/ | + | root@debian9:~# docker login |
- | [root@86252a3f00f4 | + | Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. |
- | [mongodb-org-4.2] | + | Username: < |
- | name=MongoDB Repository | + | Password: < |
- | baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/ | + | WARNING! Your password will be stored unencrypted in /root/.docker/config.json. |
- | gpgcheck=1 | + | Configure a credential helper to remove this warning. See |
- | enabled=1 | + | https://docs.docker.com/engine/reference/commandline/login/# |
- | gpgkey=https:// | + | |
- | [root@86252a3f00f4 /]# | + | Login Succeeded |
</ | </ | ||
- | Installez mongo : | + | Pour constater l' |
< | < | ||
- | [root@86252a3f00f4 /]# yum install -y mongodb-org | + | root@debian9:~# docker image pull i2tch/ |
+ | Error: remote trust data does not exist for docker.io/ | ||
</ | </ | ||
- | Démarrez mongod | + | <WRAP center round important 60%> |
+ | **Important** | ||
+ | </ | ||
- | < | + | Par contre, toutes les images de type **official** sont signées |
- | [root@86252a3f00f4 /]# mongod --config / | + | |
- | [1] 82 | + | |
- | [root@86252a3f00f4 /]# about to fork child process, waiting until server is ready for connections. | + | |
- | forked process: 84 | + | |
- | child process started successfully, | + | |
- | [1]+ Done mongod --config | + | < |
- | [root@86252a3f00f4 | + | root@debian9: |
+ | Using default tag: latest | ||
+ | Pull (1 of 1): centos: | ||
+ | sha256: | ||
+ | 729ec3a6ada3: | ||
+ | Digest: sha256: | ||
+ | Status: Downloaded newer image for centos@sha256: | ||
+ | Tagging centos@sha256: | ||
+ | docker.io/library/ | ||
</ | </ | ||
- | Vérifiez que mongod | + | Cette image est maintenant présente sur **manager.i2tch.loc** |
< | < | ||
- | [root@86252a3f00f4 /]# ps aux | + | root@debian9:~# docker images |
- | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | + | REPOSITORY |
- | root | + | ubuntu |
- | root 84 1.2 2.2 294692 46716 ? Sl | + | nginx |
- | root | + | alpine |
+ | mysql | ||
+ | centos | ||
</ | </ | ||
- | Utilisez le client mongo pour se connecter au serveur | + | ===L' |
+ | |||
+ | Il est aussi possible d' | ||
< | < | ||
- | [root@86252a3f00f4 | + | root@debian9:~# docker image pull --disable-content-trust=true i2tch/docker: |
- | MongoDB shell version: 4.2.2 | + | unsigned: Pulling from i2tch/ |
- | connecting to: test | + | 10d70a43a9f9: Pull complete |
- | Welcome to the MongoDB shell. | + | 4f4fb700ef54: |
- | For interactive help, type " | + | 8951e3a91277: |
- | For more comprehensive documentation, | + | d1814ff35b8b: |
- | http:// | + | ff2a2bbf6141: Pull complete |
- | Questions? Try the support group | + | b7205da5c3c9: |
- | http:// | + | 458ea241cc75: Pull complete |
- | Server has startup warnings: | + | 74d1c0702786: Pull complete |
- | 2019-04-09T17:16:26.951+0000 I CONTROL | + | c66f3692932d: Pull complete |
- | 2019-04-09T17:16:26.951+0000 I CONTROL | + | 9224bd1b9757: Pull complete |
- | > | + | Digest: sha256: |
- | </code> | + | Status: Downloaded newer image for i2tch/ |
+ | docker.io/i2tch/ | ||
- | Sortez de mongo et du conteneur | + | root@debian9:~# docker image ls |
+ | REPOSITORY | ||
+ | ubuntu | ||
+ | nginx | ||
+ | alpine | ||
+ | mysql | ||
+ | centos | ||
+ | i2tch/ | ||
- | < | + | root@debian9:~# docker rmi i2tch/ |
- | > exit | + | Untagged: i2tch/ |
- | bye | + | Untagged: i2tch/ |
- | [root@86252a3f00f4 /]# exit | + | Deleted: sha256: |
- | exit | + | Deleted: sha256: |
- | root@debian9:~# | + | Deleted: sha256: |
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
</ | </ | ||
- | ====1.22 - Utilisation de la commande docker | + | ====7.3 - DCT et la commande docker |
- | Créez maintenant une nouvelle | + | Pour envoyer l'image dont l' |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | CONTAINER ID IMAGE | + | |
- | 86252a3f00f4 | + | |
- | c080793965de | + | |
- | 4f157e179134 | + | |
- | 04b5ab87539a | + | |
- | root@debian9: | + | |
- | sha256:67afc80e1424a6d99179911ee499f6bf264faf2bc3c7ff4ac4a01ff9c23050a9 | + | |
</ | </ | ||
- | Supprimez le conteneur utilisé pour créer l'image : | + | L' |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | 8625 | + | REPOSITORY |
- | root@debian9: | + | ubuntu |
- | CONTAINER ID | + | nginx |
- | c080793965de | + | < |
- | 4f157e179134 | + | alpine |
- | 04b5ab87539a | + | mysql latest |
+ | centos | ||
</ | </ | ||
- | Utilisez | + | Lors du push vers le registry privé, il faut créer des passphrases pour **deux** clefs : |
+ | |||
+ | * la **root** key aussi connue sous le nom **offline** key (ID 192fc7e), qui est uniquement demandée la **première** fois après la mise en place de DCT lors de la création d'un **repositry**, | ||
+ | * la **repository** key aussi connue sous le nom **tagging** key (ID 168c754), utilisée | ||
< | < | ||
- | root@debian9: | + | root@debian9: |
- | [root@d20fb56a38b0 | + | The push refers to repository |
- | /usr/ | + | 77cae8ab23bf: |
- | / | + | alpine: digest: sha256: |
- | [root@d20fb56a38b0 /]# ps aux | + | Signing and pushing trust metadata |
- | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | + | You are about to create a new root signing key passphrase. This passphrase |
- | root | + | will be used to protect the most sensitive key in your signing system. Please |
- | root 15 0.0 0.1 51748 3468 pts/0 R+ | + | choose a long, complex passphrase and be careful to keep the password and the |
+ | key file itself secure and backed up. It is highly recommended that you use a | ||
+ | password manager to generate the passphrase and keep it safe. There will be no | ||
+ | way to recover this key. You can find the key in your config directory. | ||
+ | Enter passphrase for new root key with ID 192fc7e: fenestros | ||
+ | Repeat passphrase for new root key with ID 192fc7e: fenestros | ||
+ | Enter passphrase for new repository key with ID 168c754: fenestros | ||
+ | Repeat passphrase for new repository key with ID 168c754: fenestros | ||
+ | Finished initializing " | ||
+ | Successfully signed docker.io/< | ||
</ | </ | ||
- | Editez | + | Les clefs sont stockées dans le répertoire **~/.docker/trust/ |
< | < | ||
- | [root@d20fb56a38b0 /]# echo "/ | + | root@debian9:~# ls -l ~/.docker/trust |
- | [root@d20fb56a38b0 /]# tail /etc/bashrc | + | total 8 |
- | . " | + | drwx------ 2 root root 4096 nov. 10 14:49 private |
- | fi | + | drwx------ 3 root root 4096 nov. 8 13:48 tuf |
- | fi | + | |
- | done | + | |
- | unset i | + | root@debian9: |
- | | + | total 8 |
- | fi | + | -rw------- 1 root root 447 nov. 10 14:49 168c754ea8f36ce7fbcbe2299b6d91fc0f4d594c9ed9b86916687b618d8438ac.key |
- | # vim:ts=4:sw=4 | + | -rw------- 1 root root 416 nov. 10 14:49 192fc7ed9543ad4bceec58886ab1d605b7433c35f7462d7343d0780d8fddf1db.key |
- | /usr/bin/mongod | + | root@debian9: |
+ | -----BEGIN ENCRYPTED PRIVATE KEY----- | ||
+ | gun: docker.io/ | ||
+ | role: targets | ||
+ | |||
+ | MIHuMEkGCSqGSIb3DQEFDTA8MBsGCSqGSIb3DQEFDDAOBAhm7HwR0y8FFAICCAAw | ||
+ | HQYJYIZIAWUDBAEqBBC729tU73wKHFQSbmZ1EVZaBIGgmGiFSs4lM5tElSGukl1B | ||
+ | HrELT9aFooFgW7oSXNLM8aFfF/ | ||
+ | 3m40g3MywHilW4rUcjoHVTTUXABGXUQ3f7h+nI15CXcZ11qRLyWbf2uywE9yYH9O | ||
+ | M7GLUcE+pTENJKfZAhRGBEL+LgXNfGI1aAVqaEbBDcDnKKf4Uj1Xu4oLJ7je8+nT | ||
+ | dg== | ||
+ | -----END ENCRYPTED PRIVATE KEY----- | ||
+ | |||
+ | root@debian9: | ||
+ | -----BEGIN ENCRYPTED PRIVATE KEY----- | ||
+ | role: root | ||
+ | |||
+ | MIHuMEkGCSqGSIb3DQEFDTA8MBsGCSqGSIb3DQEFDDAOBAiAtCzEar3AhgICCAAw | ||
+ | HQYJYIZIAWUDBAEqBBAO7hHWVoqOo6xcETQQDXRdBIGgPUoLzTz07Ajx8K3D8+Vv | ||
+ | 2NUiflMYhH/0I9PL6iA2JJCmD0l+8Ueljy+vHRCu7UAIyWXyIHFN5Aab40mk9/Pg | ||
+ | V2BwSlXp7t1Cnqp/ | ||
+ | KREO8uEq3v7HcSBBqFm0+TU+92d7hVuDApPaj0lZYP+3f7H6AjUOqu6hUoK8Ck/ | ||
+ | Ig== | ||
+ | -----END ENCRYPTED PRIVATE KEY----- | ||
</ | </ | ||
- | Consultez la liste des conteneurs | + | ====7.4 - DCT et la commande docker build==== |
+ | |||
+ | L' | ||
< | < | ||
- | [root@d20fb56a38b0 /]# exit | + | root@debian9:~# mkdir nottrusted |
- | exit | + | root@debian9: |
- | root@debian9: | + | root@debian9: |
- | CONTAINER ID IMAGE | + | root@debian9:~/nottrusted# cat Dockerfile |
- | d20fb56a38b0 | + | FROM docker/trusttest: |
- | c080793965de | + | RUN echo |
- | 4f157e179134 | + | |
- | 04b5ab87539a | + | |
</ | </ | ||
- | Utilisez la commande commit pour " | + | Lors du build de l' |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | sha256:620057baa411b78a0030e192fdfbde0bb0c5ceae7bdeb115892d9946e542ee07 | + | Sending build context to Docker daemon |
+ | |||
+ | error during connect: Post http:// | ||
</ | </ | ||
- | Démarrez | + | L' |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | d20f | + | Sending build context to Docker daemon |
- | root@debian9:~# docker | + | Step 1/2 : FROM docker/ |
- | CONTAINER ID IMAGE | + | latest: Pulling from docker/ |
- | c080793965de | + | Image docker.io/ |
- | 4f157e179134 | + | aac0c133338d: |
- | 04b5ab87539a | + | a3ed95caeb02: |
- | root@debian9:~# docker | + | Digest: sha256: |
- | [root@bcec3f27ed58 | + | Status: Downloaded newer image for docker/ |
- | forked process: 16 | + | ---> cc7629d1331a |
- | child process started successfully, | + | Step 2/2 : RUN echo |
+ | ---> Running in 694e79d3cd88 | ||
- | [1]+ Done / | + | Removing intermediate container 694e79d3cd88 |
- | [root@bcec3f27ed58 /]# ps aux | + | ---> 686e85ee76b8 |
- | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | + | Successfully built 686e85ee76b8 |
- | root | + | Successfully tagged < |
- | root 16 2.0 2.4 298788 49276 ? Sl | + | |
- | root 39 0.0 0.1 51748 3476 pts/0 R+ | + | |
- | [root@bcec3f27ed58 /]# | + | |
</ | </ | ||
- | ====1.23 - Se connecter au serveur | + | Lors du push de l'image **< |
- | + | ||
- | Pour pouvoir se connecter à mongodb depuis la machine hôte, il convient d' | + | |
< | < | ||
- | [root@bcec3f27ed58 | + | root@debian9:~/nottrusted# docker push < |
- | [root@bcec3f27ed58 | + | The push refers to repository |
- | bindIp: 0.0.0.0 | + | 5f70bf18a086: |
+ | c22f7bc058a9: | ||
+ | nottrusted: digest: sha256: | ||
+ | Signing and pushing trust metadata | ||
+ | Enter passphrase for repository key with ID 168c754: fenestros | ||
+ | Successfully signed docker.io/< | ||
</ | </ | ||
- | Sortez | + | <WRAP center round important 60%> |
+ | **Important** : Notez l' | ||
+ | </ | ||
+ | |||
+ | ===Créer un deuxième Repositry=== | ||
+ | |||
+ | Par contre en modifiant | ||
< | < | ||
- | [root@bcec3f27ed58 /]# exit | + | root@debian9: |
- | exit | + | root@debian9: |
- | root@debian9: | + | REPOSITORY |
- | sha256:eca7835d4fe6a3a769046bd735ef4ad7534ac1f9bb37832d6da5db3b938d258f | + | < |
- | root@debian9: | + | < |
- | mongo | + | ubuntu |
- | root@debian9: | + | nginx latest |
- | [root@d2ddb4f8ca8a | + | < |
- | forked process: 16 | + | alpine |
- | [root@d2ddb4f8ca8a | + | mysql latest |
+ | centos | ||
+ | docker/trusttest | ||
- | [1]+ Done | + | root@debian9: |
- | [root@d2ddb4f8ca8a | + | The push refers to repository [docker.io/< |
+ | 5f70bf18a086: | ||
+ | c22f7bc058a9: | ||
+ | latest: digest: sha256: | ||
+ | Signing and pushing trust metadata | ||
+ | Enter passphrase for root key with ID 192fc7e: fenestros | ||
+ | Enter passphrase for new repository key with ID 7b13d02: fenestros | ||
+ | Repeat passphrase for new repository key with ID 7b13d02: fenestros | ||
+ | Finished initializing " | ||
+ | Successfully signed docker.io/< | ||
</ | </ | ||
- | Dans votre machine hôte, configurez le dépôt | + | <WRAP center round important 60%> |
+ | **Important** : Notez la création d'une deuxième repositry key (ID 7b13d02 au lieu de ID 168c754) lors du push de l' | ||
+ | </ | ||
+ | |||
+ | La présence de cette deuxième repositry key (**7b13d02d74264624fb201e7ae13ae694286b9f761aa86adddefd0408c7234a58.key**) peut être constatée dans le répertoire **~/ | ||
< | < | ||
- | [root@f5b45072b831 /]# exit | + | root@debian9: |
- | root@debian9: | + | total 12 |
- | root@debian9: | + | -rw------- 1 root root 447 nov. 10 14:49 168c754ea8f36ce7fbcbe2299b6d91fc0f4d594c9ed9b86916687b618d8438ac.key |
- | root@debian9: | + | -rw------- 1 root root 416 nov. 10 14:49 192fc7ed9543ad4bceec58886ab1d605b7433c35f7462d7343d0780d8fddf1db.key |
- | root@debian9: | + | -rw------- 1 root root 451 nov. 10 17:37 7b13d02d74264624fb201e7ae13ae694286b9f761aa86adddefd0408c7234a58.key |
- | Executing: /tmp/apt-key-gpghome.xMuszKS6JM/ | + | |
- | gpg: key 68818C72E52529D4: | + | |
- | gpg: Total number processed: | + | |
- | gpg: | + | |
- | root@debian9:~# | + | |
- | root@debian9:~# echo "deb http://repo.mongodb.org/ | + | |
- | deb http:// | + | |
- | root@debian9:~# | + | |
- | root@debian9:~# apt-get update | + | |
</ | </ | ||
- | Cette fois, installez uniquement le client de mongodb | + | En inspectant les clefs des images créées, l' |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | Lecture des listes de paquets... Fait | + | [ |
- | Construction de l' | + | { |
- | Lecture des informations d' | + | " |
- | Les NOUVEAUX paquets suivants seront installés : | + | " |
- | | + | { |
- | 0 mis à jour, 1 nouvellement installés, 0 à enlever et 95 non mis à jour. | + | " |
- | Il est nécessaire de prendre 9 809 ko dans les archives. | + | " |
- | Après cette opération, 39,8 Mo d' | + | " |
- | Réception de:1 http://repo.mongodb.org/ | + | " |
- | 9 809 ko réceptionnés en 7s (1 245 ko/s) | + | ] |
- | Sélection du paquet mongodb-org-shell précédemment désélectionné. | + | } |
- | (Lecture de la base de données... 91513 fichiers et répertoires déjà installés.) | + | ], |
- | Préparation du dépaquetage de .../ | + | " |
- | Dépaquetage de mongodb-org-shell (4.0.8) ... | + | " |
- | Paramétrage de mongodb-org-shell (4.0.8) ... | + | { |
- | Traitement des actions différées (« triggers ») pour man-db (2.7.6.1-2) ... | + | " |
+ | " | ||
+ | { | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
+ | root@debian9:~/nottrusted# docker trust inspect < | ||
+ | [ | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | "Repo Admin" | ||
+ | | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
</ | </ | ||
- | Notez qu'à ce stade le conteneur ne possède pas d' | + | <WRAP center round important 60%> |
+ | **Important** | ||
+ | </ | ||
< | < | ||
- | root@debian9: | + | root@debian9: |
- | "LinkLocalIPv6Address": "", | + | [ |
- | "LinkLocalIPv6PrefixLen": | + | { |
- | "SecondaryIPAddresses": | + | |
- | | + | "SignedTags": |
- | "GlobalIPv6Address": "", | + | |
- | "GlobalIPv6PrefixLen": | + | |
- | "IPAddress": "", | + | "Digest": "1183c62a5d31e202b5f5f528e9e7cdc36140aa3212c938e1d471c6b3b59f01bc", |
- | "IPPrefixLen": | + | "Signers": |
- | "IPv6Gateway": "", | + | "Repo Admin" |
- | "IPAMConfig": | + | ] |
- | "IPAddress": "" | + | } |
- | | + | ], |
- | "IPv6Gateway": "", | + | |
- | "GlobalIPv6Address": | + | "AdministrativeKeys": |
- | "GlobalIPv6PrefixLen": | + | |
+ | | ||
+ | "Keys": | ||
+ | | ||
+ | | ||
+ | | ||
+ | ] | ||
+ | }, | ||
+ | { | ||
+ | | ||
+ | "Keys": | ||
+ | | ||
+ | | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
</ | </ | ||
- | Démarrez donc le conteneur et cherchez l' | + | <WRAP center round important 60%> |
+ | **Important** | ||
+ | </ | ||
- | < | + | ===Supprimer une Signature=== |
- | root@debian9: | + | |
- | mongo | + | |
- | root@debian9: | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | </ | + | |
- | Connectez-vous maintenant à votre mongodb à partir | + | Dernièrement il est possible |
< | < | ||
- | root@debian9: | + | root@debian9: |
- | MongoDB shell version v4.0.8 | + | Enter passphrase for repository key with ID 168c754: |
- | connecting to: mongodb://172.17.0.3:27017/? | + | Successfully deleted signature for < |
- | WARNING: No implicit session: Logical Sessions are only supported on server versions 3.6 and greater. | + | root@debian9:~# docker trust inspect < |
- | Implicit session: dummy session | + | [ |
- | MongoDB server version: 4.2.2 | + | { |
- | WARNING: shell and server versions do not match | + | " |
- | Welcome to the MongoDB shell. | + | " |
- | For interactive help, type "help". | + | " |
- | For more comprehensive documentation, see | + | " |
- | http:// | + | { |
- | Questions? Try the support group | + | "Name": "Root", |
- | http:// | + | " |
- | Server has startup warnings: | + | { |
- | 2019-04-09T17: | + | " |
- | 2019-04-09T17:31: | + | } |
- | > | + | ] |
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
</ | </ | ||
+ | |||
----- | ----- | ||
< | < | ||
<div align=" | <div align=" | ||
- | Copyright © 2021 Hugh Norris | + | Copyright © 2021 Hugh NORRIS |
</ | </ | ||
</ | </ | ||
- |