Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| elearning:workbooks:debian:11:sec:l109 [2025/12/02 13:24] – créée admin | elearning:workbooks:debian:11:sec:l109 [2025/12/07 16:38] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 5: | Ligne 5: | ||
| Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
| - | ======LDF409 - Démarrer avec Docker====== | + | ======LDF409 - Gestion de la Sécurité de Docker====== |
| =====Contenu du Module===== | =====Contenu du Module===== | ||
| - | * **LDF409 - Démarrer avec Docker** | + | * **LDF409 - Gestion de la Sécurité de Docker** |
| * Contenu du Module | * Contenu du Module | ||
| - | * Présentation de Docker | + | * LAB #1 - Utilisation des Docker |
| - | * LAB #1 - Travailler avec Docker | + | * LAB #2 - Création d'un Utilisateur de Confiance pour Contrôler le Daemon |
| - | * 1.1 - Installer | + | * LAB #3 - Le Script |
| - | * 1.2 - Démarrer un Conteneur | + | * LAB #4 - Sécurisation de la Configuration de l' |
| - | * 1.3 - Consulter | + | * LAB #5 - Sécurisation de la Configuration du daemon Docker |
| - | * 1.4 - Rechercher une Image dans un Dépôt | + | * 5.1 - Le Fichier / |
| - | * 1.5 - Supprimer un Conteneur d'une Image | + | * LAB #6 - Sécurisation des Images et les Fichiers de Construction |
| - | * 1.6 - Créer une Image à partir d'un Conteneur Modifié | + | * LAB #7 - Sécurisation du Container Runtime |
| - | * 1.7 - Supprimer une Image | + | * LAB #8 - Sécurisation des Images |
| - | * 1.8 - Créer un Conteneur | + | * 8.1 - DOCKER_CONTENT_TRUST |
| - | * 1.9 - Exécuter une Commande dans un Conteneur | + | * 8.2 - DCT et la commande docker pull |
| - | * 1.10 - Injecter des Variables d' | + | * L'option disable-content-trust |
| - | * 1.11 - Modifier le Nom d' | + | * 8.3 - DCT et la commande docker push |
| - | * 1.12 - Mapper des Ports d'un Conteneur | + | * 8.4 - DCT et la commande docker build |
| - | * 1.13 - Démarrer un Conteneur en mode Détaché | + | * Créer |
| - | * 1.14 - Accéder aux Services d'un Conteneur de l' | + | * Supprimer une Signature |
| - | * 1.15 - Arrêter | + | * LAB #9 - Sécurisation du Socket du Daemon Docker |
| - | * 1.16 - Utiliser des Signaux avec un Conteneur | + | * 9.1 - Création du Certificat de l' |
| - | * 1.17 - Forcer la Suppression d'un Conteneur en cours d' | + | * 9.2 - Création du Certificat du Serveur Hôte du Daemon Docker |
| - | * 1.18 - Utilisation Simple d'un Volume | + | * 9.3 - Création du Certificat du Client |
| - | * 1.19 - Télécharger une image sans créer un conteneur | + | * 9.4 - Démarrage du Daemon Docker avec une Invocation Directe |
| - | * 1.20 - S' | + | * 9.5 - Configuration |
| - | * 1.21 - Installer un logiciel dans le conteneur | + | |
| - | * 1.22 - Utilisation de la commande docker commit | + | |
| - | * 1.23 - Se connecter au serveur | + | |
| - | =====Présentation de Docker===== | + | =====LAB #1 - Utilisation des Docker |
| - | Docker | + | Les secrets |
| - | Une **image** est un paquet exécutable contenant tout ce qu'il est necessaire afin d'exécuter | + | Considérez l'exemple suivant |
| - | * le code | + | < |
| - | * un runtime | + | version: '3.1' |
| - | * des bibliothèques, | + | |
| - | * des variables d'environnement | + | |
| - | * des fichiers de configuration | + | |
| - | Un **conteneur** est une instance de l' | + | services: |
| - | Les conteneurs exécutent des applications nativement en utilisant le noyau de la machine hôte. De ce fait les performances d'un conteneur sont supérieures à celles d'une machine virtuelle qui doit passer par un hyperviseur pour accéder aux ressources de la machine hôte. | + | db: |
| + | image: postgres | ||
| + | environment: | ||
| + | POSTGRES_USER: | ||
| + | POSTGRES_PASSWORD: | ||
| + | POSTGRES_DB: | ||
| - | Docker existe en deux versions **Docker-CE** (Docker Community Edition) et **Docker-EE** (Docker Enterprise Edition). Pour consulter les différences entre les deux versions, consultez le lien **[[https:// | + | adminer: |
| + | image: adminer | ||
| + | ports: | ||
| + | - 8080:8080 | ||
| + | </file> | ||
| - | =====LAB #1 - Travailler avec Docker===== | + | On peut constater dans ce fichier la présence des informations sensibles en non-sécurisées : |
| - | ====1.1 - Installer docker==== | + | * POSTGRES_USER |
| + | * POSTGRES_PASSWORD | ||
| + | * POSTGRES_DB | ||
| - | Installer Docker-CE sur **votre** ordinateur | + | Afin de sécuriser ces informations, |
| - | ==Mac== | + | < |
| + | root@manager: | ||
| + | </ | ||
| - | | + | Créez ensuite un Docker Secret appelé |
| - | ==Linux== | + | < |
| + | root@manager: | ||
| + | root@manager: | ||
| + | lpk8eq80qvfiqw7z1686fmj5t | ||
| + | </ | ||
| - | | + | <WRAP center round important 50%> |
| - | * Debian | + | **Important** : Notez l' |
| - | * CentOS - voir le lien **[[https:// | + | </WRAP> |
| - | * Fedora - voir le lien **[[https:// | + | |
| - | ==Windows 7, 8== | + | Pour visualiser la liste des secrets, utilisez la commande docker secrets **ls** : |
| - | * Téléchargez Docker Toolbox à partir de cette page **[[https://docs.docker.com/ | + | < |
| - | * Fermez toutes les machines virtuelles ainsi que VirtualBox, | + | root@manager:~/postgres# |
| - | * Installez **DockerToolBox.exe** (décochez VirtualBox dans la liste de produits à installer), | + | ID NAME DRIVER |
| - | * Exécutez Docker Toolbox et laissez l' | + | lpk8eq80qvfiqw7z1686fmj5t |
| - | * Ouvrez VirtualBox. Vous verrez une machine virtuelle Default, | + | </ |
| - | * Ouvrez **cmd**. | + | |
| - | ==Windows 10== | + | <WRAP center round important 50%> |
| + | **Important** : Notez que la colonne **DRIVER** est vide. Ceci indique que le gestion des secrets est accomplie par Docker lui-même au lieu d' | ||
| + | </ | ||
| - | | + | Créez maintenant les secrets |
| + | < | ||
| + | root@manager: | ||
| + | h9tsfbfwz6o0sd35roklwpopi | ||
| + | root@manager: | ||
| + | 5lx4zydpfocwgpdto0yy1jod9 | ||
| + | </ | ||
| - | ====1.2 - Démarrer | + | <WRAP center round important 50%> |
| + | **Important** : Notez qu'un secret Docker est immuable. | ||
| + | </ | ||
| - | Démarrez un conteneur | + | Vérifiez la prise en compte |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/postgres# docker |
| - | Unable to find image ' | + | ID NAME DRIVER |
| - | latest: Pulling from library/ | + | 5lx4zydpfocwgpdto0yy1jod9 |
| - | 1b930d010525: | + | h9tsfbfwz6o0sd35roklwpopi |
| - | Digest: sha256: | + | lpk8eq80qvfiqw7z1686fmj5t |
| - | Status: Downloaded newer image for hello-world: | + | </ |
| - | Hello from Docker! | + | Pour obtenir de l' |
| - | 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@manager:~/postgres# docker secret inspect pg_database |
| - | 2. The Docker daemon pulled the "hello-world" | + | [ |
| - | | + | { |
| - | 3. The Docker daemon created a new container from that image which runs the | + | |
| - | | + | " |
| - | 4. The Docker daemon streamed that output to the Docker client, which sent it | + | " |
| - | | + | }, |
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | | ||
| + | ] | ||
| + | </ | ||
| - | To try something more ambitious, you can run an Ubuntu container with: | + | <WRAP center round important 50%> |
| - | $ docker run -it ubuntu bash | + | **Important** |
| + | </ | ||
| - | Share images, automate workflows, and more with a free Docker ID: | + | L' |
| - | | + | |
| - | For more examples and ideas, visit: | + | < |
| - | https://docs.docker.com/get-started/ | + | root@manager:~/postgres# |
| + | ID: 5lx4zydpfocwgpdto0yy1jod9 | ||
| + | Name: pg_database | ||
| + | Driver: | ||
| + | Created at: 2021-04-15 03:49:36.344367554 +0000 utc | ||
| + | Updated at: 2021-04-15 03: | ||
| </ | </ | ||
| - | <WRAP center round important> | + | Créez maintenant le fichier compose **postgres-secrets.yaml** : |
| - | **Important** - Notez que si l' | + | |
| + | <code> | ||
| + | root@manager: | ||
| + | root@manager: | ||
| + | version: ' | ||
| + | |||
| + | services: | ||
| + | |||
| + | db: | ||
| + | image: postgres | ||
| + | restart: always | ||
| + | environment: | ||
| + | POSTGRES_USER_FILE: | ||
| + | POSTGRES_PASSWORD_FILE: | ||
| + | POSTGRES_DB_FILE: | ||
| + | secrets: | ||
| + | - pg_password | ||
| + | - pg_user | ||
| + | - pg_database | ||
| + | |||
| + | adminer: | ||
| + | image: adminer | ||
| + | ports: | ||
| + | - 8080:8080 | ||
| + | |||
| + | secrets: | ||
| + | pg_user: | ||
| + | external: true | ||
| + | pg_password: | ||
| + | external: true | ||
| + | pg_database: | ||
| + | external: true | ||
| + | </ | ||
| + | |||
| + | Notez que dans ce fichier les trois variables | ||
| + | |||
| + | Deuxièmement la section suivantes spécifie les noms des secrets à utiliser avec le service : | ||
| + | |||
| + | < | ||
| + | secrets: | ||
| + | - pg_password | ||
| + | - pg_user | ||
| + | - pg_database | ||
| + | </ | ||
| + | |||
| + | La dernière section spécifie que les secrets sont **externes** : | ||
| + | |||
| + | < | ||
| + | secrets: | ||
| + | pg_user: | ||
| + | external: true | ||
| + | pg_password: | ||
| + | external: true | ||
| + | pg_database: | ||
| + | external: true | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 50%> | ||
| + | **Important** : Le terme **externe** indique que les secrets ne seront pas stockés dans l' | ||
| </ | </ | ||
| - | Démarrez un conteneur de l' | + | Déployez maintenant le service |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/postgres# docker |
| - | Unable to find image ' | + | Ignoring unsupported options: restart |
| - | latest: Pulling from library/ | + | |
| - | 898c46f3b1a1: | + | Creating network postgres_default |
| - | 63366dfa0a50: | + | Creating service postgres_db |
| - | 041d4cd74a92: | + | Creating service postgres_adminer |
| - | 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> | + | <WRAP center round important |
| - | **Important** | + | **Important** |
| </ | </ | ||
| - | Consulter | + | Connectez-vous maintenant à Apache Guacamole et ouvrez un navigateur web dans la machine virtuelle. Naviguez ensuite à l' |
| + | |||
| + | {{ : | ||
| + | |||
| + | Validez le formulaire et vérifiez que les secrets ont été pris en compte : | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | Dernièrement, | ||
| < | < | ||
| - | root@835001339e79:/# | + | root@manager: |
| - | Desired=Unknown/ | + | NAME SERVICES |
| - | | Status=Not/ | + | postgres |
| - | |/ Err? | + | root@manager:~/postgres# docker stack rm postgres |
| - | ||/ Name | + | Removing service postgres_adminer |
| - | +++-====================================-=======================-=======================-============================================================================= | + | Removing service postgres_db |
| - | ii adduser | + | Removing network postgres_default |
| - | ii apt 1.6.8 | + | |
| - | ii base-files | + | |
| - | 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 | + | |
| - | 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 | + | |
| - | exit | + | |
| - | root@debian9: | + | |
| </ | </ | ||
| - | Les options | + | =====LAB #2 - Création d'un Utilisateur |
| + | |||
| + | Au contraire des solutions classiques de gestion de machines virtuelles où l' | ||
| < | < | ||
| - | root@debian9:~# docker run --help | + | root@manager:~# cat /etc/group | grep docker |
| + | docker: | ||
| + | root@manager: | ||
| + | root@manager: | ||
| + | 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: | ||
| + | CONTAINER ID IMAGE | ||
| + | a214e2df0499 | ||
| + | </ | ||
| - | Usage: docker | + | =====LAB #3 - Le Script |
| - | Run a command in a new container | + | Le **Center for Internet Security (CIS)** est une organisation indépendante à but non-lucratif qui publie des best practices dans de nombreux domaines de l' |
| - | Options: | + | Le guide est divisé en plusieurs sections |
| - | | + | |
| - | | + | |
| - | | + | * La configuration du daemon Docker, |
| - | --blkio-weight-device list Block IO weight (relative device weight) (default []) | + | |
| - | --cap-add list Add Linux capabilities | + | * Les images ainsi que les fichiers servant à la construction des images, |
| - | --cap-drop list Drop Linux capabilities | + | * Le container runtime, |
| - | --cgroup-parent string | + | |
| - | --cidfile string | + | * La configuration de Docker Swarm. |
| - | --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period | + | |
| - | --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota | + | Ce guide est à utiliser avec le script **Docker Benchmark Security**. |
| - | --cpu-rt-period int Limit CPU real-time period in microseconds | + | |
| - | --cpu-rt-runtime int Limit CPU real-time runtime in microseconds | + | Clonez le script **docker-bench-security.sh** en utilisant **git** : |
| - | | + | |
| - | | + | < |
| - | --cpuset-cpus string | + | trainee@manager: |
| - | | + | Password: fenestros |
| - | | + | |
| - | | + | root@manager: |
| - | | + | Cloning |
| - | | + | remote: Enumerating objects: 18, done. |
| - | | + | remote: Counting objects: 100% (18/18), done. |
| - | --device-read-iops list Limit read rate (IO per second) from a device (default []) | + | remote: Compressing objects: 100% (16/16), done. |
| - | | + | remote: Total 1921 (delta 5), reused 6 (delta 2), pack-reused 1903 |
| - | | + | Receiving objects: 100% (1921/1921), 2.90 MiB | 908.00 KiB/s, done. |
| - | --disable-content-trust | + | Delta resolution: 100% (1339/1339), done. |
| - | --dns list Set custom DNS servers | + | |
| - | | + | |
| - | --dns-search list Set custom DNS search domains | + | |
| - | | + | |
| - | -e, --env list Set environment variables | + | |
| - | --env-file list Read in a file of environment variables | + | |
| - | | + | |
| - | --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 | + | |
| - | | + | |
| - | --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-swap bytes Swap limit equal to memory plus swap: ' | + | |
| - | --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) | + | |
| - | | + | |
| - | --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 | + | |
| - | | + | |
| - | --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 | + | |
| - | | + | |
| - | --volumes-from list Mount volumes from the specified container(s) | + | |
| - | -w, --workdir string | + | |
| </ | </ | ||
| - | ====1.3 - Consulter la Liste des Conteneurs | + | Exécutez maintenant le script **Docker Benchmark Security** : |
| + | |||
| + | < | ||
| + | root@manager: | ||
| + | |||
| + | root@manager: | ||
| + | # -------------------------------------------------------------------------------------------- | ||
| + | # Docker Bench for Security v1.6.0 | ||
| + | # | ||
| + | # Docker, Inc. (c) 2015-2023 | ||
| + | # | ||
| + | # Checks for dozens of common best-practices around deploying Docker containers in production. | ||
| + | # Based on the CIS Docker Benchmark 1.6.0. | ||
| + | # -------------------------------------------------------------------------------------------- | ||
| + | |||
| + | Initializing 2023-12-17T14: | ||
| + | |||
| + | |||
| + | Section A - Check results | ||
| + | |||
| + | [INFO] 1 - Host Configuration | ||
| + | [INFO] 1.1 - Linux Hosts Specific Configuration | ||
| + | [WARN] 1.1.1 - Ensure a separate partition for containers has been created (Automated) | ||
| + | [INFO] 1.1.2 - Ensure only trusted users are allowed to control Docker daemon (Automated) | ||
| + | [INFO] | ||
| + | [WARN] 1.1.3 - Ensure auditing is configured for the Docker daemon (Automated) | ||
| + | [WARN] 1.1.4 - Ensure auditing is configured for Docker files and directories -/ | ||
| + | [WARN] 1.1.5 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [WARN] 1.1.6 - Ensure auditing is configured for Docker files and directories - /etc/docker (Automated) | ||
| + | [WARN] 1.1.7 - Ensure auditing is configured for Docker files and directories - docker.service (Automated) | ||
| + | [INFO] 1.1.8 - Ensure auditing is configured for Docker files and directories - containerd.sock (Automated) | ||
| + | [INFO] | ||
| + | [WARN] 1.1.9 - Ensure auditing is configured for Docker files and directories - docker.socket (Automated) | ||
| + | [WARN] 1.1.10 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [INFO] 1.1.11 - Ensure auditing is configured for Dockerfiles and directories - / | ||
| + | [INFO] | ||
| + | [WARN] 1.1.12 - 1.1.12 Ensure auditing is configured for Dockerfiles and directories - / | ||
| + | [INFO] 1.1.13 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [INFO] | ||
| + | [WARN] 1.1.14 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [WARN] 1.1.15 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [INFO] 1.1.16 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [INFO] | ||
| + | [INFO] 1.1.17 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [INFO] | ||
| + | [WARN] 1.1.18 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [INFO] 1.2 - General Configuration | ||
| + | [NOTE] 1.2.1 - Ensure the container host has been Hardened (Manual) | ||
| + | [PASS] 1.2.2 - Ensure that the version of Docker is up to date (Manual) | ||
| + | [INFO] | ||
| + | |||
| + | [INFO] 2 - Docker daemon configuration | ||
| + | [NOTE] 2.1 - Run the Docker daemon as a non-root user, if possible (Manual) | ||
| + | [WARN] 2.2 - Ensure network traffic is restricted between containers on the default bridge (Scored) | ||
| + | [PASS] 2.3 - Ensure the logging level is set to ' | ||
| + | [PASS] 2.4 - Ensure Docker is allowed to make changes to iptables (Scored) | ||
| + | [PASS] 2.5 - Ensure insecure registries are not used (Scored) | ||
| + | [PASS] 2.6 - Ensure aufs storage driver is not used (Scored) | ||
| + | [INFO] 2.7 - Ensure TLS authentication for Docker daemon is configured (Scored) | ||
| + | [INFO] | ||
| + | [INFO] 2.8 - Ensure the default ulimit is configured appropriately (Manual) | ||
| + | [INFO] | ||
| + | [WARN] 2.9 - Enable user namespace support (Scored) | ||
| + | [PASS] 2.10 - Ensure the default cgroup usage has been confirmed (Scored) | ||
| + | [PASS] 2.11 - Ensure base device size is not changed until needed (Scored) | ||
| + | [WARN] 2.12 - Ensure that authorization for Docker client commands is enabled (Scored) | ||
| + | [WARN] 2.13 - Ensure centralized and remote logging is configured (Scored) | ||
| + | [WARN] 2.14 - Ensure containers are restricted from acquiring new privileges (Scored) | ||
| + | [WARN] 2.15 - Ensure live restore is enabled (Scored) | ||
| + | [WARN] 2.16 - Ensure Userland Proxy is Disabled (Scored) | ||
| + | [PASS] 2.17 - Ensure that a daemon-wide custom seccomp profile is applied if appropriate (Manual) | ||
| + | [PASS] 2.18 - Ensure that experimental features are not implemented in production (Scored) | ||
| + | |||
| + | [INFO] 3 - Docker daemon configuration files | ||
| + | [PASS] 3.1 - Ensure that the docker.service file ownership is set to root:root (Automated) | ||
| + | [PASS] 3.2 - Ensure that docker.service file permissions are appropriately set (Automated) | ||
| + | [PASS] 3.3 - Ensure that docker.socket file ownership is set to root:root (Automated) | ||
| + | [PASS] 3.4 - Ensure that docker.socket file permissions are set to 644 or more restrictive (Automated) | ||
| + | [PASS] 3.5 - Ensure that the /etc/docker directory ownership is set to root:root (Automated) | ||
| + | [PASS] 3.6 - Ensure that /etc/docker directory permissions are set to 755 or more restrictively (Automated) | ||
| + | [INFO] 3.7 - Ensure that registry certificate file ownership is set to root:root (Automated) | ||
| + | [INFO] | ||
| + | [INFO] 3.8 - Ensure that registry certificate file permissions are set to 444 or more restrictively (Automated) | ||
| + | [INFO] | ||
| + | [INFO] 3.9 - Ensure that TLS CA certificate file ownership is set to root:root (Automated) | ||
| + | [INFO] | ||
| + | [INFO] 3.10 - Ensure that TLS CA certificate file permissions are set to 444 or more restrictively (Automated) | ||
| + | [INFO] | ||
| + | [INFO] 3.11 - Ensure that Docker server certificate file ownership is set to root:root (Automated) | ||
| + | [INFO] | ||
| + | [INFO] 3.12 - Ensure that the Docker server certificate file permissions are set to 444 or more restrictively (Automated) | ||
| + | [INFO] | ||
| + | [INFO] 3.13 - Ensure that the Docker server certificate key file ownership is set to root:root (Automated) | ||
| + | [INFO] | ||
| + | [INFO] 3.14 - Ensure that the Docker server certificate key file permissions are set to 400 (Automated) | ||
| + | [INFO] | ||
| + | [PASS] 3.15 - Ensure that the Docker socket file ownership is set to root:docker (Automated) | ||
| + | [PASS] 3.16 - Ensure that the Docker socket file permissions are set to 660 or more restrictively (Automated) | ||
| + | [INFO] 3.17 - Ensure that the daemon.json file ownership is set to root:root (Automated) | ||
| + | [INFO] | ||
| + | [INFO] 3.18 - Ensure that daemon.json file permissions are set to 644 or more restrictive (Automated) | ||
| + | [INFO] | ||
| + | [PASS] 3.19 - Ensure that the / | ||
| + | [PASS] 3.20 - Ensure that the / | ||
| + | [INFO] 3.21 - Ensure that the / | ||
| + | [INFO] | ||
| + | [INFO] 3.22 - Ensure that the / | ||
| + | [INFO] | ||
| + | [PASS] 3.23 - Ensure that the Containerd socket file ownership is set to root:root (Automated) | ||
| + | [PASS] 3.24 - Ensure that the Containerd socket file permissions are set to 660 or more restrictively (Automated) | ||
| + | |||
| + | [INFO] 4 - Container Images and Build File | ||
| + | [INFO] 4.1 - Ensure that a user for the container has been created (Automated) | ||
| + | [INFO] | ||
| + | [NOTE] 4.2 - Ensure that containers use only trusted base images (Manual) | ||
| + | [NOTE] 4.3 - Ensure that unnecessary packages are not installed in the container (Manual) | ||
| + | [NOTE] 4.4 - Ensure images are scanned and rebuilt to include security patches (Manual) | ||
| + | [WARN] 4.5 - Ensure Content trust for Docker is Enabled (Automated) | ||
| + | [WARN] 4.6 - Ensure that HEALTHCHECK instructions have been added to container images (Automated) | ||
| + | [WARN] | ||
| + | [WARN] | ||
| + | [WARN] | ||
| + | [WARN] | ||
| + | [PASS] 4.7 - Ensure update instructions are not used alone in the Dockerfile (Manual) | ||
| + | [NOTE] 4.8 - Ensure setuid and setgid permissions are removed (Manual) | ||
| + | [PASS] 4.9 - Ensure that COPY is used instead of ADD in Dockerfiles (Manual) | ||
| + | [NOTE] 4.10 - Ensure secrets are not stored in Dockerfiles (Manual) | ||
| + | [NOTE] 4.11 - Ensure only verified packages are installed (Manual) | ||
| + | [NOTE] 4.12 - Ensure all signed artifacts are validated (Manual) | ||
| + | |||
| + | [INFO] 5 - Container Runtime | ||
| + | [INFO] | ||
| + | |||
| + | [INFO] 6 - Docker Security Operations | ||
| + | [INFO] 6.1 - Ensure that image sprawl is avoided (Manual) | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] 6.2 - Ensure that container sprawl is avoided (Manual) | ||
| + | [INFO] | ||
| + | |||
| + | [INFO] 7 - Docker Swarm Configuration | ||
| + | [WARN] 7.1 - Ensure swarm mode is not Enabled, if not needed (Automated) | ||
| + | [PASS] 7.2 - Ensure that the minimum number of manager nodes have been created in a swarm (Automated) (Swarm mode not enabled) | ||
| + | [PASS] 7.3 - Ensure that swarm services are bound to a specific host interface (Automated) (Swarm mode not enabled) | ||
| + | [PASS] 7.4 - Ensure that all Docker swarm overlay networks are encrypted (Automated) | ||
| + | [PASS] 7.5 - Ensure that Docker' | ||
| + | [PASS] 7.6 - Ensure that swarm manager is run in auto-lock mode (Automated) (Swarm mode not enabled) | ||
| + | [PASS] 7.7 - Ensure that the swarm manager auto-lock key is rotated periodically (Manual) (Swarm mode not enabled) | ||
| + | [PASS] 7.8 - Ensure that node certificates are rotated as appropriate (Manual) (Swarm mode not enabled) | ||
| + | [PASS] 7.9 - Ensure that CA certificates are rotated as appropriate (Manual) (Swarm mode not enabled) | ||
| + | [PASS] 7.10 - Ensure that management plane traffic is separated from data plane traffic (Manual) (Swarm mode not enabled) | ||
| + | |||
| + | |||
| + | Section C - Score | ||
| + | |||
| + | [INFO] Checks: 86 | ||
| + | [INFO] Score: 1 | ||
| + | </ | ||
| + | |||
| + | Ce script sert à automatiser le contrôle des points précédemment cités et produit un rapport contenant des annotations : | ||
| + | |||
| + | * **[PASS]** : Concerne les points qui n'ont pas besoin d' | ||
| + | * **[WARN]** : Concerne les points qui **doivent** être modifiés, | ||
| + | * **[INFO]** : Concerne les points qui doivent être passés en revue selon les besoins de votre configuration, | ||
| + | * **[NOTE]** : Vous informe d'un **best practice**. | ||
| + | |||
| + | =====LAB #4 - Sécurisation de la Configuration de l' | ||
| + | |||
| + | Lors de l' | ||
| + | |||
| + | < | ||
| + | ... | ||
| + | [INFO] 1 - Host Configuration | ||
| + | [INFO] 1.1 - Linux Hosts Specific Configuration | ||
| + | [WARN] 1.1.1 - Ensure a separate partition for containers has been created (Automated) | ||
| + | [INFO] 1.1.2 - Ensure only trusted users are allowed to control Docker daemon (Automated) | ||
| + | [INFO] | ||
| + | [WARN] 1.1.3 - Ensure auditing is configured for the Docker daemon (Automated) | ||
| + | [WARN] 1.1.4 - Ensure auditing is configured for Docker files and directories -/ | ||
| + | [WARN] 1.1.5 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [WARN] 1.1.6 - Ensure auditing is configured for Docker files and directories - /etc/docker (Automated) | ||
| + | [WARN] 1.1.7 - Ensure auditing is configured for Docker files and directories - docker.service (Automated) | ||
| + | [INFO] 1.1.8 - Ensure auditing is configured for Docker files and directories - containerd.sock (Automated) | ||
| + | [INFO] | ||
| + | [WARN] 1.1.9 - Ensure auditing is configured for Docker files and directories - docker.socket (Automated) | ||
| + | [WARN] 1.1.10 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [INFO] 1.1.11 - Ensure auditing is configured for Dockerfiles and directories - / | ||
| + | [INFO] | ||
| + | [WARN] 1.1.12 - 1.1.12 Ensure auditing is configured for Dockerfiles and directories - / | ||
| + | [INFO] 1.1.13 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [INFO] | ||
| + | [WARN] 1.1.14 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [WARN] 1.1.15 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [INFO] 1.1.16 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [INFO] | ||
| + | [INFO] 1.1.17 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [INFO] | ||
| + | [WARN] 1.1.18 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [INFO] 1.2 - General Configuration | ||
| + | [NOTE] 1.2.1 - Ensure the container host has been Hardened (Manual) | ||
| + | [PASS] 1.2.2 - Ensure that the version of Docker is up to date (Manual) | ||
| + | [INFO] | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | Les problèmes de sécurité qu'il convient à résoudre sont indiqués par les annotations **[WARN]**. | ||
| + | |||
| + | ====[WARN] 1.1.1 - Ensure a separate partition for containers has been created (Automated)==== | ||
| + | |||
| + | Par défaut, tous les fichiers de Docker sont stockés dans le répertoire **/ | ||
| + | |||
| + | ====[WARN] 1.1.3 - Ensure auditing is configured for the Docker daemon (Automated)==== | ||
| + | |||
| + | < | ||
| + | [WARN] 1.1.4 - Ensure auditing is configured for Docker files and directories -/ | ||
| + | [WARN] 1.1.5 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [WARN] 1.1.6 - Ensure auditing is configured for Docker files and directories - /etc/docker (Automated) | ||
| + | [WARN] 1.1.7 - Ensure auditing is configured for Docker files and directories - docker.service (Automated) | ||
| + | [WARN] 1.1.9 - Ensure auditing is configured for Docker files and directories - docker.socket (Automated) | ||
| + | [WARN] 1.1.10 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [WARN] 1.1.12 - Ensure auditing is configured for Dockerfiles and directories - / | ||
| + | [WARN] 1.1.14 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [WARN] 1.1.15 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [WARN] 1.1.18 - Ensure auditing is configured for Docker files and directories - / | ||
| + | </ | ||
| + | |||
| + | 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. | ||
| - | Pour consulter tous les conteneurs, utilisez la commande | + | Editez le fichier |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/ |
| - | CONTAINER ID IMAGE | + | |
| - | 3a3f9bda6cbd | + | root@manager: |
| - | 26ef17bd115d | + | deb http:// |
| + | deb-src http:// | ||
| + | deb http:// | ||
| + | deb-src http:// | ||
| + | deb [arch=amd64] https:// | ||
| </ | </ | ||
| - | <WRAP center round important> | + | Exécutez la commande |
| - | **Important** - Notez que chaque conteneur peut être référencé par son **CONTAINER ID** ou par son **NAME**. | + | |
| - | </WRAP> | + | < |
| + | root@manager: | ||
| + | Ign:1 http:// | ||
| + | Atteint:2 http:// | ||
| + | Atteint:3 http:// | ||
| + | Réception de:4 https:// | ||
| + | 44,8 ko réceptionnés en 0s (107 ko/s) | ||
| + | Lecture des listes de paquets... Fait | ||
| + | Construction de l' | ||
| + | Lecture des informations d' | ||
| + | 254 packages can be upgraded. Run 'apt list --upgradable' | ||
| + | </code> | ||
| - | Pour consulter la liste des images, utilisez | + | Pour installer auditd, utilisez **apt-get** : |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/ |
| - | REPOSITORY | + | </ |
| - | ubuntu | + | |
| - | hello-world | + | Modifiez ensuite le fichier **/ |
| + | |||
| + | < | ||
| + | root@manager: | ||
| + | |||
| + | root@manager: | ||
| + | ## First rule - delete all | ||
| + | -D | ||
| + | |||
| + | ## Increase the buffers to survive stress events. | ||
| + | ## Make this bigger for busy systems | ||
| + | -b 8192 | ||
| + | |||
| + | ## This determine how long to wait in burst of events | ||
| + | --backlog_wait_time 0 | ||
| + | |||
| + | ## Set failure mode to syslog | ||
| + | -f 1 | ||
| + | |||
| + | ##Docker | ||
| + | -w / | ||
| + | -w / | ||
| + | -w /etc/docker -p wa | ||
| + | -w / | ||
| + | -w / | ||
| + | -w / | ||
| + | -w / | ||
| + | -w / | ||
| + | -w / | ||
| + | -w / | ||
| + | -w / | ||
| + | -w / | ||
| + | -w / | ||
| + | -w / | ||
| </ | </ | ||
| - | <WRAP center round important> | + | <WRAP center round important |
| - | **Important** - Notez que chaque image est référencée par son IMAGE ID. | + | **Important** : L' |
| </ | </ | ||
| - | ====1.4 | + | Re-démarrez ensuite auditd : |
| - | Pour rechercher une image docker | + | < |
| + | root@manager: | ||
| + | </ | ||
| + | |||
| + | Vérifiez ensuite | ||
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/docker-bench-security# cat / |
| - | NAME DESCRIPTION | + | ## This file is automatically generated from /etc/audit/rules.d |
| - | centos | + | -D |
| - | ansible/centos7-ansible | + | -b 8192 |
| - | jdeathe/centos-ssh | + | -f 1 |
| - | consol/ | + | --backlog_wait_time 0 |
| - | imagine10255/ | + | -w / |
| - | centos/ | + | -w /var/lib/ |
| - | tutum/centos | + | -w /etc/ |
| - | gluster/gluster-centos | + | -w /lib/ |
| - | openshift/base-centos7 | + | -w / |
| - | centos/postgresql-96-centos7 | + | -w /etc/ |
| - | centos/python-35-centos7 | + | -w / |
| - | kinogmt/ | + | -w /usr/ |
| - | centos/httpd-24-centos7 | + | -w /usr/ |
| - | centos/php-56-centos7 | + | -w /usr/bin/containerd |
| - | openshift/jenkins-2-centos7 | + | -w /run/containerd |
| - | pivotaldata/centos-gpdb-dev | + | -w / |
| - | openshift/wildfly-101-centos7 | + | -w /usr/bin/containerd-shim -p wa |
| + | -w /usr/bin/runc -p wa | ||
| </ | </ | ||
| - | <WRAP center round important> | + | <WRAP center round important |
| - | **Important** - Notez que chaque image est référencée par la colonne NAME. Le NAME est sous le format | + | **Important** - Pour plus d' |
| </ | </ | ||
| - | ====1.5 | + | Ré-exécutez le script **Docker Benchmark Security** : |
| - | Pour supprimer | + | < |
| + | root@manager: | ||
| + | ... | ||
| + | [PASS] 1.1.4 - Ensure auditing is configured for Docker files and directories -/ | ||
| + | [PASS] 1.1.5 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [PASS] 1.1.6 - Ensure auditing is configured for Docker files and directories - /etc/docker (Automated) | ||
| + | [PASS] 1.1.7 - Ensure auditing is configured for Docker files and directories - docker.service (Automated) | ||
| + | [PASS] 1.1.9 - Ensure auditing is configured for Docker files and directories - docker.socket (Automated) | ||
| + | [PASS] 1.1.10 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [PASS] 1.1.12 - Ensure auditing is configured for Dockerfiles and directories - / | ||
| + | [PASS] 1.1.14 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [PASS] 1.1.15 - Ensure auditing is configured for Docker files and directories - / | ||
| + | [PASS] 1.1.18 - Ensure auditing is configured for Docker files and directories - / | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | =====LAB #5 - Sécurisation de la Configuration du daemon Docker===== | ||
| + | |||
| + | 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 : | ||
| + | |||
| + | < | ||
| + | ... | ||
| + | [INFO] 2 - Docker daemon configuration | ||
| + | [NOTE] 2.1 - Run the Docker daemon as a non-root user, if possible (Manual) | ||
| + | [WARN] 2.2 - Ensure network traffic is restricted between containers on the default bridge (Scored) | ||
| + | [PASS] 2.3 - Ensure the logging level is set to ' | ||
| + | [PASS] 2.4 - Ensure Docker is allowed to make changes to iptables (Scored) | ||
| + | [PASS] 2.5 - Ensure insecure registries are not used (Scored) | ||
| + | [PASS] 2.6 - Ensure aufs storage driver is not used (Scored) | ||
| + | [INFO] 2.7 - Ensure TLS authentication for Docker daemon is configured (Scored) | ||
| + | [INFO] | ||
| + | [INFO] 2.8 - Ensure the default ulimit is configured appropriately (Manual) | ||
| + | [INFO] | ||
| + | [WARN] 2.9 - Enable user namespace support (Scored) | ||
| + | [PASS] 2.10 - Ensure the default cgroup usage has been confirmed (Scored) | ||
| + | [PASS] 2.11 - Ensure base device size is not changed until needed (Scored) | ||
| + | [WARN] 2.12 - Ensure that authorization for Docker client commands is enabled (Scored) | ||
| + | [WARN] 2.13 - Ensure centralized and remote logging is configured (Scored) | ||
| + | [WARN] 2.14 - Ensure containers are restricted from acquiring new privileges (Scored) | ||
| + | [WARN] 2.15 - Ensure live restore is enabled (Scored) | ||
| + | [WARN] 2.16 - Ensure Userland Proxy is Disabled (Scored) | ||
| + | [PASS] 2.17 - Ensure that a daemon-wide custom seccomp profile is applied if appropriate (Manual) | ||
| + | [PASS] 2.18 - Ensure that experimental features are not implemented in production (Scored) | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | Les problèmes de sécurité qu'il convient à résoudre sont indiqués par les annotations **[WARN]**. | ||
| + | |||
| + | ====[WARN] 2.2 - Ensure network traffic is restricted between containers on the default bridge (Scored)==== | ||
| + | |||
| + | 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 la configuration par défaut. | ||
| + | |||
| + | Pour plus d' | ||
| + | |||
| + | ====[WARN] 2.9 - Enable user namespace support (Scored)==== | ||
| + | |||
| + | Cet avertissement nous indique que l' | ||
| + | |||
| + | Pour plus d'informations, | ||
| + | |||
| + | ====[WARN] 2.12 - Ensure that authorization for Docker client commands is enabled (Scored)==== | ||
| + | |||
| + | Par défaut, Docker permet un accès sans restrictions aux daemon Docker. Il est possible de restreindre l' | ||
| + | |||
| + | Pour plus d' | ||
| + | |||
| + | ====[WARN] 2.13 - Ensure centralized and remote logging is configured (Scored)==== | ||
| + | |||
| + | Cet avertissement indique que la configuration de rsyslog ne permet pas l' | ||
| + | |||
| + | Pour plus d' | ||
| + | |||
| + | ====[WARN] 2.14 - Ensure containers are restricted from acquiring new privileges (Scored)==== | ||
| + | |||
| + | Par défaut un conteneur peut obtenir | ||
| + | |||
| + | Pour plus d' | ||
| + | |||
| + | ====[WARN] 2.15 - Ensure live restore is enabled (Scored)==== | ||
| + | |||
| + | L' | ||
| + | |||
| + | ====[WARN] 2.16 - Ensure Userland Proxy is Disabled (Scored)==== | ||
| + | |||
| + | Il existe deux méthodes pour qu'un conteneur puisse router vers l' | ||
| + | |||
| + | * le mode **Hairpin NAT**, | ||
| + | * **Userland Proxy**. | ||
| + | |||
| + | Il est préférable | ||
| + | |||
| + | Pour plus d' | ||
| + | |||
| + | ====5.1 - Le Fichier / | ||
| + | |||
| + | Créez | ||
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/docker-bench-security# vi /etc/ |
| - | CONTAINER ID IMAGE | + | |
| - | 3a3f9bda6cbd | + | root@manager:~/ |
| - | 26ef17bd115d | + | { |
| - | root@debian9:~# docker | + | " |
| - | wizardly_buck | + | " |
| - | root@debian9:~# docker ps -a | + | " |
| - | CONTAINER ID IMAGE | + | " |
| - | 26ef17bd115d | + | " |
| - | root@debian9:~# docker images | + | " |
| - | REPOSITORY | + | } |
| - | ubuntu | + | |
| - | hello-world | + | |
| </ | </ | ||
| - | <WRAP center round important> | + | Re-démarrez |
| - | **Important** | + | |
| - | </ | + | |
| - | ====1.6 | + | < |
| + | root@manager: | ||
| + | </ | ||
| - | Modifier un conteneur d'une image : | + | Vérifiez la présence de l'utilisateur dénommé **dockremap** |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/docker-bench-security# id dockremap |
| - | root@54b0dae2f3a9:/# | + | uid=116(dockremap) gid=121(dockremap) groupes=121(dockremap) |
| - | 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> | + | Ré-exécutez |
| - | **Important** | + | |
| - | </ | + | |
| - | Consultez la différence entre le conteneur et l'image de base : | + | < |
| + | root@manager: | ||
| + | ... | ||
| + | [PASS] 2.2 - Ensure network traffic is restricted between containers on the default bridge (Scored) | ||
| + | [PASS] 2.3 - Ensure the logging level is set to 'info' (Scored) | ||
| + | [PASS] 2.4 - Ensure Docker is allowed to make changes to iptables (Scored) | ||
| + | [PASS] 2.5 - Ensure insecure registries are not used (Scored) | ||
| + | [PASS] 2.6 - Ensure aufs storage driver is not used (Scored) | ||
| + | [PASS] 2.9 - Enable user namespace support (Scored) | ||
| + | [PASS] 2.10 - Ensure the default cgroup usage has been confirmed (Scored) | ||
| + | [PASS] 2.11 - Ensure | ||
| + | [PASS] 2.13 - Ensure centralized and remote logging is configured (Scored) | ||
| + | [PASS] 2.14 - Ensure containers are restricted from acquiring new privileges (Scored) | ||
| + | [PASS] 2.15 - Ensure live restore is enabled (Scored) | ||
| + | [PASS] 2.16 - Ensure Userland Proxy is Disabled (Scored) | ||
| + | [PASS] 2.17 - Ensure that a daemon-wide custom seccomp profile is applied if appropriate (Manual) | ||
| + | [PASS] 2.18 - Ensure that experimental features are not implemented in production (Scored) | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | Pour plus d' | ||
| + | |||
| + | =====LAB #6 - Sécurisation des Images et les Fichiers de Construction===== | ||
| + | |||
| + | Créez le conteneur mysql : | ||
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/ |
| - | CONTAINER ID IMAGE | + | Lecture des listes de paquets... Fait |
| - | 54b0dae2f3a9 | + | Construction de l' |
| - | 26ef17bd115d | + | Lecture des informations d' |
| - | root@debian9:~# docker | + | Le paquet suivant |
| - | C /root | + | |
| - | A /root/.bash_history | + | Veuillez utiliser « apt autoremove » pour le supprimer. |
| - | D /home | + | Les paquets suivants seront mis à jour : |
| + | docker-ce | ||
| + | 1 mis à jour, 0 nouvellement installés, 0 à enlever et 252 non mis à jour. | ||
| + | Il est nécessaire de prendre 22,7 Mo dans les archives. | ||
| + | Après cette opération, 497 ko d' | ||
| + | Réception de:1 https://download.docker.com/ | ||
| + | 22,7 Mo réceptionnés en 0s (26,0 Mo/s) | ||
| + | Lecture des fichiers de modifications (« changelog »)... Terminé | ||
| + | (Lecture de la base de données... 112865 fichiers et répertoires déjà installés.) | ||
| + | Préparation du dépaquetage de .../docker-ce_5%3a19.03.15~3-0~debian-stretch_amd64.deb ... | ||
| + | Dépaquetage de docker-ce | ||
| + | Paramétrage de docker-ce (5: | ||
| + | Traitement des actions différées (« triggers ») pour systemd (232-25+deb9u14) ... | ||
| + | |||
| + | root@manager:~/ | ||
| + | Unable to find image ' | ||
| + | latest: Pulling from library/mysql | ||
| + | e9f2695d7e5b: | ||
| + | 80c6055edb33: | ||
| + | c646ab461d8b: | ||
| + | 012006c6a591: | ||
| + | 929d5fa34b95: | ||
| + | 17e0243877fa: | ||
| + | 1850b459cd2f: | ||
| + | 8dceaed53baf: | ||
| + | 197b834ea1cd: | ||
| + | 8df78c25b227: | ||
| + | Digest: sha256: | ||
| + | Status: Downloaded newer image for mysql: | ||
| + | e503dd98f88992ae6ed5ec4dcaa2e18982ade8ec74966869515a120763418f74 | ||
| + | |||
| + | root@manager:~/docker-bench-security# | ||
| + | CONTAINER ID IMAGE | ||
| + | e503dd98f889 | ||
| </ | </ | ||
| - | <WRAP center round important> | + | Exécutez |
| - | **Important** - La sortie | + | |
| - | </ | + | |
| - | Créez un autre conteneur | + | < |
| + | root@manager: | ||
| + | ... | ||
| + | [INFO] 4 - Container Images and Build File | ||
| + | [WARN] 4.1 - Ensure that a user for the container has been created (Automated) | ||
| + | [WARN] | ||
| + | [NOTE] 4.2 - Ensure that containers use only trusted base images (Manual) | ||
| + | [NOTE] 4.3 - Ensure that unnecessary packages are not installed in the container (Manual) | ||
| + | [NOTE] 4.4 - Ensure images are scanned and rebuilt to include security patches (Manual) | ||
| + | [WARN] 4.5 - Ensure Content trust for Docker is Enabled (Automated) | ||
| + | [WARN] 4.6 - Ensure that HEALTHCHECK instructions have been added to container images (Automated) | ||
| + | [WARN] | ||
| + | [PASS] 4.7 - Ensure update instructions are not used alone in the Dockerfile (Manual) | ||
| + | [NOTE] 4.8 - Ensure setuid and setgid permissions are removed (Manual) | ||
| + | [PASS] 4.9 - Ensure that COPY is used instead of ADD in Dockerfiles (Manual) | ||
| + | [NOTE] 4.10 - Ensure secrets are not stored in Dockerfiles (Manual) | ||
| + | [NOTE] 4.11 - Ensure only verified packages are installed (Manual) | ||
| + | [NOTE] 4.12 - Ensure all signed artifacts are validated (Manual) | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | ====[WARN] 4.1 - Ensure that a user for the container has been created (Automated)==== | ||
| + | |||
| + | Les processus dans le conteneur | ||
| + | |||
| + | Pour plus d' | ||
| + | |||
| + | ====[WARN] 4.5 - Ensure Content trust for Docker is Enabled (Automated)==== | ||
| + | |||
| + | 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:~# docker | + | root@manager:~/docker-bench-security# |
| - | root@92f0d4bb7967: | + | DOCKER_CONTENT_TRUST=1 |
| - | bin boot dev | + | |
| - | root@92f0d4bb7967: | + | root@manager:~/ |
| - | exit | + | |
| - | root@debian9:~# | + | |
| </ | </ | ||
| - | <WRAP center round important> | + | Re-démarrez la machine virtuelle |
| - | **Important** - Dans ce nouveau conteneur, | + | |
| - | </ | + | |
| - | Créez maintenant | + | < |
| + | root@manager: | ||
| + | Connection to 10.0.2.62 closed by remote host. | ||
| + | Connection to 10.0.2.62 closed. | ||
| + | |||
| + | root@debian11: | ||
| + | trainee@10.0.2.62's password: trainee | ||
| + | Linux manager.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | ||
| + | |||
| + | The programs included with the Debian GNU/Linux system are free software; | ||
| + | the exact distribution terms for each program are described in the | ||
| + | individual files in / | ||
| + | |||
| + | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | ||
| + | permitted by applicable law. | ||
| + | Last login: Sun Dec 17 18:39:07 2023 from 10.0.2.46 | ||
| + | |||
| + | trainee@manager: | ||
| + | Mot de passe : fenestros | ||
| + | |||
| + | root@manager: | ||
| + | |||
| + | root@manager: | ||
| + | |||
| + | root@manager: | ||
| + | mysql | ||
| + | </ | ||
| + | |||
| + | Exécutez de nouveau le script et notez le contenu de la section 4 : | ||
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/ |
| - | CONTAINER ID IMAGE | + | ... |
| - | 92f0d4bb7967 | + | [INFO] 4 - Container Images and Build File |
| - | 54b0dae2f3a9 | + | [WARN] 4.1 - Ensure that a user for the container has been created (Automated) |
| - | 26ef17bd115d | + | [WARN] |
| - | root@debian9: | + | [NOTE] 4.2 - Ensure that containers use only trusted base images |
| - | sha256: | + | [NOTE] 4.3 - Ensure that unnecessary packages are not installed in the container |
| - | root@debian9:~# docker images | + | [NOTE] 4.4 - Ensure images are scanned and rebuilt to include security patches |
| - | REPOSITORY | + | [PASS] 4.5 - Ensure Content trust for Docker is Enabled (Automated) |
| - | ubuntu_1 | + | [WARN] 4.6 - Ensure that HEALTHCHECK instructions have been added to container images (Automated) |
| - | ubuntu | + | [WARN] |
| - | hello-world | + | [PASS] 4.7 - Ensure update instructions are not used alone in the Dockerfile (Manual) |
| + | [NOTE] 4.8 - Ensure setuid and setgid permissions are removed (Manual) | ||
| + | [PASS] | ||
| + | [NOTE] 4.10 - Ensure secrets are not stored in Dockerfiles (Manual) | ||
| + | [NOTE] | ||
| + | [NOTE] 4.12 - Ensure all signed artifacts are validated (Manual) | ||
| + | ... | ||
| </ | </ | ||
| - | ====1.7 - Supprimer une Image==== | + | Pour plus d' |
| - | Créez maintenant | + | ====[WARN] 4.6 - Ensure that HEALTHCHECK instructions have been added to container images==== |
| + | |||
| + | Quand une image est construite il est possible d'y mettre | ||
| + | |||
| + | Pour mettre en place un HEALTHCHECK, | ||
| + | |||
| + | < | ||
| + | HEALTHCHECK --interval=20s --timeout=3s CMD curl -f http:// | ||
| + | </ | ||
| + | |||
| + | Ce test permet de vérifier que le conteneur peut atteindre l'URL indiqué tous les 20 secondes et produit une erreur au bout de 3 secondes. | ||
| + | |||
| + | Pour plus d' | ||
| + | |||
| + | =====LAB #7 - Sécurisation du Container Runtime===== | ||
| + | |||
| + | Exécutez de nouveau le script **docker-bench-security.sh**, | ||
| < | < | ||
| - | root@debian9:~# docker run -it ubuntu_1 | + | root@manager:~/ |
| - | root@904215fb79b4:/# ls | + | ... |
| - | bin boot dev etc lib lib64 media mnt opt proc | + | [INFO] 5 - Container Runtime |
| - | root@904215fb79b4: | + | [WARN] 5.1 - Ensure that, if applicable, an AppArmor Profile is enabled (Automated) |
| - | exit | + | [WARN] |
| - | root@debian9:~# | + | [WARN] 5.2 - Ensure that, if applicable, SELinux security options are set (Automated) |
| + | [WARN] | ||
| + | [PASS] 5.3 - Ensure that Linux kernel capabilities are restricted within containers (Automated) | ||
| + | [PASS] 5.4 - Ensure that privileged containers are not used (Automated) | ||
| + | [PASS] 5.5 - Ensure sensitive host system directories are not mounted on containers (Automated) | ||
| + | [PASS] 5.6 - Ensure sshd is not run within containers (Automated) | ||
| + | [PASS] 5.7 - Ensure privileged ports are not mapped within containers (Automated) | ||
| + | [PASS] 5.8 - Ensure that only needed ports are open on the container (Manual) | ||
| + | [PASS] 5.9 - Ensure that the host's network namespace is not shared (Automated) | ||
| + | [WARN] 5.10 - Ensure that the memory usage for containers is limited (Automated) | ||
| + | [WARN] | ||
| + | [WARN] 5.11 - Ensure that CPU priority is set appropriately on containers (Automated) | ||
| + | [WARN] | ||
| + | [WARN] 5.12 - Ensure that the container' | ||
| + | [WARN] | ||
| + | [PASS] 5.13 - Ensure that incoming container traffic is bound to a specific host interface (Automated) | ||
| + | [WARN] 5.14 - Ensure that the ' | ||
| + | [WARN] | ||
| + | [PASS] 5.15 - Ensure that the host's process namespace is not shared (Automated) | ||
| + | [PASS] 5.16 - Ensure that the host's IPC namespace is not shared (Automated) | ||
| + | [PASS] 5.17 - Ensure that host devices are not directly exposed to containers (Manual) | ||
| + | [INFO] 5.18 - Ensure that the default ulimit is overwritten at runtime if needed (Manual) | ||
| + | [INFO] | ||
| + | [PASS] 5.19 - Ensure mount propagation mode is not set to shared (Automated) | ||
| + | [PASS] 5.20 - Ensure that the host's UTS namespace is not shared (Automated) | ||
| + | [PASS] 5.21 - Ensure the default seccomp profile is not Disabled (Automated) | ||
| + | [NOTE] 5.22 - Ensure that docker exec commands are not used with the privileged option (Automated) | ||
| + | [NOTE] 5.23 - Ensure that docker exec commands are not used with the user=root option (Manual) | ||
| + | [PASS] 5.24 - Ensure that cgroup usage is confirmed (Automated) | ||
| + | [PASS] 5.25 - Ensure that the container is restricted from acquiring additional privileges (Automated) | ||
| + | [WARN] 5.26 - Ensure that container health is checked at runtime (Automated) | ||
| + | [WARN] | ||
| + | [INFO] 5.27 - Ensure that Docker commands always make use of the latest version of their image (Manual) | ||
| + | [WARN] 5.28 - Ensure that the PIDs cgroup limit is used (Automated) | ||
| + | [WARN] | ||
| + | [INFO] 5.29 - Ensure that Docker' | ||
| + | [INFO] | ||
| + | [PASS] 5.30 - Ensure that the host's user namespaces are not shared (Automated) | ||
| + | [PASS] 5.31 - Ensure that the Docker socket is not mounted inside any containers (Automated) | ||
| + | ... | ||
| </ | </ | ||
| - | <WRAP center round important> | + | Les problèmes de sécurité qu'il convient à résoudre sont indiqués par les annotations |
| - | **Important** - Notez l'absence du répertoire **home** dans le conteneur | + | |
| - | </ | + | |
| - | Essayez de supprimer l'image **ubuntu_1** : | + | ====[WARN] 5.1 - Ensure that, if applicable, an AppArmor Profile is enabled (Automated)==== |
| + | |||
| + | Cet avertissement est présent parce que le conteneur n'utilise pas AppArmor. | ||
| + | |||
| + | Pour plus d' | ||
| + | |||
| + | ====[WARN] 5.2 - Ensure that, if applicable, SELinux security options are set (Automated)==== | ||
| + | |||
| + | Cet avertissement est présent parce que le conteneur n' | ||
| + | |||
| + | Pour plus d' | ||
| + | |||
| + | ====[WARN] 5.10 - Ensure that the memory usage for containers is limited (Automated)==== | ||
| + | |||
| + | Cet avertissement est du au fait que les conteneurs ont automatiquement accès à la totalité de la RAM de l' | ||
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~# docker |
| - | Error response from daemon: conflict: unable to remove repository reference " | + | b04b2a6f0dd93da21a8b7640afc319406e42868a141f90936dbcf52ab5bffb0d |
| - | root@debian9:~# docker | + | root@manager:~# docker |
| - | CONTAINER ID | + | CONTAINER ID |
| - | 904215fb79b4 | + | b04b2a6f0dd9 |
| - | 92f0d4bb7967 | + | ^C |
| - | 54b0dae2f3a9 | + | |
| - | 26ef17bd115d | + | |
| </ | </ | ||
| - | <WRAP center round important> | + | Supprimez le conteneur et re-créez le avec une limite de mémoire : |
| - | **Important** - Notez qu' | + | |
| + | <code> | ||
| + | root@manager: | ||
| + | Unable to find image ' | ||
| + | sha256: | ||
| + | 1f7ce2fa46ab: | ||
| + | 9b16c94bb686: | ||
| + | 9a59d19f9c5b: | ||
| + | 9ea27b074f71: | ||
| + | c6edf33e2524: | ||
| + | 84b1ff10387b: | ||
| + | 517357831967: | ||
| + | Digest: sha256: | ||
| + | Status: Downloaded newer image for nginx@sha256: | ||
| + | Tagging nginx@sha256: | ||
| + | e14d5112c2feb71e6f37252bcf99d03603d6b7a3e200bff0d55611a0e9a25e2b | ||
| + | |||
| + | root@manager: | ||
| + | CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O | ||
| + | e14d5112c2fe | ||
| + | e503dd98f889 | ||
| + | ^C | ||
| + | </ | ||
| + | |||
| + | Supprimez le conteneur et re-créez-le avec une limite de mémoire : | ||
| + | |||
| + | < | ||
| + | root@manager: | ||
| + | CONTAINER ID IMAGE | ||
| + | e14d5112c2fe | ||
| + | e503dd98f889 | ||
| + | |||
| + | root@manager: | ||
| + | e14 | ||
| + | |||
| + | root@manager: | ||
| + | 38e91e096c83f7cbe78089617a4d70110bd273f53339f8fed8df2503d3cd65ca | ||
| + | |||
| + | root@manager: | ||
| + | CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O | ||
| + | 38e91e096c83 | ||
| + | e503dd98f889 | ||
| + | ^C | ||
| + | </ | ||
| + | |||
| + | Pour plus d' | ||
| + | |||
| + | ====[WARN] 5.11 - Ensure that CPU priority is set appropriately on containers (Automated)==== | ||
| + | |||
| + | Cet avertissement est du au fait que les conteneurs ont automatiquement accès à tous les CPU de l' | ||
| + | |||
| + | La valeur de cpu-shares est relative à la valeur par défaut de **1024**. Un valeur de 512 permet au conteneur d' | ||
| + | |||
| + | Pour plus d'informations, | ||
| + | |||
| + | ====[WARN] 5.12 - Ensure that the container' | ||
| + | |||
| + | Afin de minimiser le risque de compromettre un conteneur par la présence de code malicieux, il est conseillé | ||
| + | |||
| + | Créez le fichier | ||
| + | |||
| + | < | ||
| + | root@manager: | ||
| + | </ | ||
| + | |||
| + | La Commande **docker container diff** indique les différences apportées au conteneur par rapport à l' | ||
| + | |||
| + | < | ||
| + | root@manager: | ||
| + | C /run | ||
| + | C / | ||
| + | A / | ||
| + | A / | ||
| + | A / | ||
| + | A / | ||
| + | A / | ||
| + | A / | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 50%> | ||
| + | **Important** : Notez que la sortie indique les changements apportés au conteneur. | ||
| </ | </ | ||
| - | Supprimez donc le conteneur | + | Arrêtez et supprimez |
| < | < | ||
| - | root@debian9:~# docker rm priceless_swirles | + | root@manager:~/docker-bench-security# docker |
| - | priceless_swirles | + | mysql |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | root@manager:~/ |
| - | 92f0d4bb7967 | + | mysql |
| - | 54b0dae2f3a9 | + | |
| - | 26ef17bd115d | + | |
| - | root@debian9: | + | |
| - | Untagged: ubuntu_1: | + | |
| - | Deleted: sha256: | + | |
| - | Deleted: sha256: | + | |
| - | root@debian9:~# docker | + | |
| - | REPOSITORY | + | |
| - | ubuntu | + | |
| - | hello-world | + | |
| </ | </ | ||
| - | Pour pouvoir supprimer tous les conteneurs, listez-les par leur **Container ID** : | + | Lancez un conteneur mysql en lecture seule : |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/ |
| - | 92f0d4bb7967 | + | 711ab28bdfb41220c84246c1658bcde398681a78291bbbe7d3bbfd9bc317d41b |
| - | 54b0dae2f3a9 | + | |
| - | 26ef17bd115d | + | |
| </ | </ | ||
| - | Supprimer toutes les conteneurs | + | Créez le fichier **write_a_file** dans le conteneur **mysql** |
| < | < | ||
| - | root@debian9:~# docker rm `docker | + | root@manager:~/docker-bench-security# docker |
| - | 92f0d4bb7967 | + | touch: cannot touch '/ |
| - | 54b0dae2f3a9 | + | |
| - | 26ef17bd115d | + | |
| - | root@debian9: | + | |
| - | root@debian9:~# | + | |
| </ | </ | ||
| - | Pour supprimer un conteneur dès la fin de son exécution, utilisez | + | <WRAP center round important 50%> |
| + | **Important** : Notez l'erreur | ||
| + | </ | ||
| + | |||
| + | Exécutez la commande **docker container diff** : | ||
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/docker-bench-security# docker container diff mysql |
| - | root@d123b0112fc2:/ | + | root@manager:~/docker-bench-security# |
| - | bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | |
| - | root@d123b0112fc2:/# exit | + | |
| - | exit | + | |
| - | root@debian9: | + | |
| - | root@debian9: | + | |
| </ | </ | ||
| - | ====1.8 - Créer un Conteneur avec un Nom Spécifique==== | + | <WRAP center round important 50%> |
| + | **Important** : Notez que la commande ne retourne aucune sortie. En effet le conteneur étant en lecture seule, aucun changement ne peut intervenir. | ||
| + | </ | ||
| + | |||
| + | ====[WARN] 5.14 - Ensure that the ' | ||
| + | |||
| + | Cet avertissement concerne la politique de re-démarrage du conteneur. La politique **on-failure[: | ||
| + | |||
| + | # docker container run -d --name mysql --read-only --restart on-failure: | ||
| + | |||
| + | Pour plus d' | ||
| + | |||
| + | ====[WARN] 5.26 - Ensure that container health is checked at runtime (Automated)==== | ||
| + | |||
| + | Voir l' | ||
| + | |||
| + | ====[WARN] 5.28 - Ensure that the PIDs cgroup limit is used (Automated)==== | ||
| - | Créez maintenant | + | Sans l' |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/docker-bench-security# docker |
| - | root@04b5ab87539a:/ | + | |
| - | bin boot dev etc home lib lib64 media mnt opt proc root | + | |
| - | root@04b5ab87539a:/# | + | |
| - | exit | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | 04b5ab87539a | + | |
| </ | </ | ||
| - | Pour obtenir | + | L' |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/docker-bench-security# docker run -u 1000 --pids-limit 100 ubuntu bash -c ":() { : | : & }; :; while [[ true ]]; do sleep 1; done" |
| - | [ | + | Unable to find image ' |
| - | { | + | sha256:6042500cf4b44023ea1894effe7890666b0c5c7871ed83a97c36c76ae560bb9b: Pulling from library/ubuntu |
| - | " | + | a48641193673: Pull complete |
| - | " | + | Digest: sha256:6042500cf4b44023ea1894effe7890666b0c5c7871ed83a97c36c76ae560bb9b |
| - | " | + | Status: Downloaded newer image for ubuntu@sha256:6042500cf4b44023ea1894effe7890666b0c5c7871ed83a97c36c76ae560bb9b |
| - | " | + | Tagging ubuntu@sha256:6042500cf4b44023ea1894effe7890666b0c5c7871ed83a97c36c76ae560bb9b as ubuntu:latest |
| - | " | + | environment: fork: retry: Resource temporarily unavailable |
| - | " | + | environment: fork: retry: Resource temporarily unavailable |
| - | " | + | environment: fork: retry: Resource temporarily unavailable |
| - | " | + | environment: fork: retry: Resource temporarily unavailable |
| - | " | + | environment: fork: retry: Resource temporarily unavailable |
| - | " | + | environment: fork: retry: Resource temporarily unavailable |
| - | " | + | environment: fork: retry: Resource temporarily unavailable |
| - | " | + | environment: fork: retry: Resource temporarily unavailable |
| - | " | + | environment: fork: retry: Resource temporarily unavailable |
| - | " | + | environment: fork: retry: Resource temporarily unavailable |
| - | " | + | environment: fork: retry: Resource temporarily unavailable |
| - | " | + | environment: fork: retry: Resource temporarily unavailable |
| - | }, | + | ^P^Q |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | 0, | + | |
| - | 0 | + | |
| - | ], | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | "/proc/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | ], | + | |
| - | " | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | ] | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | ], | + | |
| - | " | + | |
| - | "/ | + | |
| - | ], | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | } | + | |
| - | } | + | |
| - | } | + | |
| - | ] | + | |
| </ | </ | ||
| - | ====1.9 - Exécuter une Commande dans un Conteneur==== | + | Pour plus d' |
| - | Pour exécuter une commande spécifique dans un conteneur, passez la commande en argument | + | Supprimez maintenant tous les conteneurs déjà créées |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/ |
| - | PATH=/ | + | db5ae43c3e55 |
| - | HOSTNAME=77bb110031aa | + | f3b2528fbac0 |
| - | HOME=/root | + | 711ab28bdfb4 |
| - | root@debian9:~# | + | |
| + | root@manager:~/ | ||
| + | CONTAINER ID IMAGE | ||
| </ | </ | ||
| - | ====1.10 | + | Re-créez le conteneur mysql en intégrant les points vus ci-dessus : |
| + | |||
| + | < | ||
| + | root@manager: | ||
| + | f49d1ffdeae2e83435e8cc3a2e03fb2e0b33e5609d266e5a3403ff8859e5d122 | ||
| + | |||
| + | root@manager: | ||
| + | CONTAINER ID IMAGE | ||
| + | f49d1ffdeae2 | ||
| + | </ | ||
| - | Pour injecter une ou des variables d' | + | Exécutez de nouveau le script **docker-bench-security.sh**, vous devez obtenir |
| < | < | ||
| - | root@debian9:~# vi env.list | + | root@manager:~/ |
| - | root@debian9:~# cat env.list | + | ... |
| - | EDITOR=vim | + | [PASS] 5.2 - Ensure that, if applicable, SELinux security options are set (Automated) |
| - | HOSTNAME=ubuntudocker | + | [PASS] 5.10 - Ensure that the memory usage for containers is limited (Automated) |
| + | [PASS] 5.11 - Ensure that CPU priority is set appropriately on containers (Automated) | ||
| + | [PASS] 5.12 - Ensure that the container' | ||
| + | [PASS] 5.14 - Ensure that the ' | ||
| + | [PASS] 5.28 - Ensure that the PIDs cgroup limit is used (Automated) | ||
| + | ... | ||
| </ | </ | ||
| + | |||
| + | =====LAB #8 - Sécurisation des Images avec Docker Content Trust===== | ||
| + | |||
| + | **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' | ||
| + | |||
| + | 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:// | ||
| + | |||
| + | DCT est basé sur l' | ||
| + | |||
| + | Pour plus d' | ||
| + | |||
| + | ====8.1 - DOCKER_CONTENT_TRUST==== | ||
| + | |||
| + | Pour utiliser **Docker Content Trust (DCT)**, il convient de vérifier que la valeur de la variable **DOCKER_CONTENT_TRUST** est **1** : | ||
| < | < | ||
| - | root@debian9:~# docker run --rm --env-file=env.list ubuntu env | + | root@manager:~# echo $DOCKER_CONTENT_TRUST |
| - | PATH=/ | + | 1 |
| - | HOSTNAME=ubuntudocker | + | |
| - | EDITOR=vim | + | |
| - | HOME=/ | + | |
| - | root@debian9: | + | |
| </ | </ | ||
| - | ====1.11 - Modifier | + | Dans le cas contraire, il faut fixer la valeur de la variable à 1 : |
| - | Pour modifier le nom d' | + | < |
| + | root@manager: | ||
| + | root@manager: | ||
| + | 1 | ||
| + | </ | ||
| + | |||
| + | ====8.2 - DCT et la commande docker pull==== | ||
| + | |||
| + | Afin d'utiliser | ||
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~# docker |
| - | root@ubuntudocker:/# hostname | + | 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:// |
| - | ubuntudocker | + | Username: < |
| - | root@ubuntudocker:/# exit | + | Password: < |
| - | exit | + | WARNING! Your password will be stored unencrypted in /root/ |
| - | root@debian9:~# | + | Configure a credential helper to remove this warning. See |
| + | https:// | ||
| + | |||
| + | Login Succeeded | ||
| </ | </ | ||
| - | ====1.12 - Mapper des Ports d' | + | Pour constater l'impact de l' |
| - | Démarrer un conteneur | + | < |
| + | root@manager: | ||
| + | Error: remote trust data does not exist for docker.io/ | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 50%> | ||
| + | **Important** : Notez l' | ||
| + | </ | ||
| + | |||
| + | Par contre, toutes les images | ||
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~# docker |
| - | Unable to find image 'nginx:latest' locally | + | Using default tag: latest |
| - | latest: Pulling from library/nginx | + | Pull (1 of 1): centos:latest@sha256: |
| - | 27833a3ba0a5: | + | sha256: |
| - | e83729dd399a: | + | 729ec3a6ada3: Pull complete |
| - | ebc6a67df66d: Pull complete | + | Digest: sha256:f94c1d992c193b3dc09e297ffd54d8a4f1dc946c37cbeceb26d35ce1647f88d9 |
| - | Digest: sha256:c8a861b8a1eeef6d48955a6c6d5dff8e2580f13ff4d0f549e082e7c82a8617a2 | + | Status: Downloaded newer image for centos@sha256:f94c1d992c193b3dc09e297ffd54d8a4f1dc946c37cbeceb26d35ce1647f88d9 |
| - | Status: Downloaded newer image for nginx:latest | + | Tagging centos@sha256:f94c1d992c193b3dc09e297ffd54d8a4f1dc946c37cbeceb26d35ce1647f88d9 as centos: |
| - | ^Croot@debian9:~# | + | docker.io/ |
| </ | </ | ||
| - | Notez que c'est bloquant. Le fait d' | + | Cette image est maintenant présente sur **manager.i2tch.loc** |
| < | < | ||
| - | ^Croot@debian9:~# docker | + | root@manager:~# docker |
| - | CONTAINER ID | + | REPOSITORY |
| - | 4f157e179134 | + | ubuntu |
| - | 04b5ab87539a | + | nginx latest |
| + | alpine | ||
| + | mysql | ||
| + | centos | ||
| </ | </ | ||
| - | ====1.13 - Démarrer un Conteneur en mode Détaché==== | + | ===L' |
| - | Démarrez maintenant le conteneur | + | Il est aussi possible d' |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~# docker |
| - | aabb064d4b0ade1f19216b6174631fa32a2053f6aa9d59bd724ea90ce534b004 | + | unsigned: Pulling from i2tch/ |
| - | root@debian9:~# docker | + | 10d70a43a9f9: |
| - | CONTAINER ID | + | 4f4fb700ef54: |
| - | aabb064d4b0a | + | 8951e3a91277: |
| - | 4f157e179134 | + | d1814ff35b8b: |
| - | 04b5ab87539a | + | ff2a2bbf6141: |
| + | b7205da5c3c9: | ||
| + | 458ea241cc75: | ||
| + | 74d1c0702786: | ||
| + | c66f3692932d: | ||
| + | 9224bd1b9757: | ||
| + | Digest: sha256: | ||
| + | Status: Downloaded newer image for i2tch/ | ||
| + | docker.io/ | ||
| + | |||
| + | root@manager:~# docker | ||
| + | REPOSITORY | ||
| + | ubuntu | ||
| + | nginx latest | ||
| + | alpine | ||
| + | mysql | ||
| + | centos | ||
| + | i2tch/ | ||
| + | |||
| + | root@manager: | ||
| + | Untagged: i2tch/ | ||
| + | Untagged: i2tch/ | ||
| + | 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: | ||
| + | Deleted: sha256: | ||
| + | Deleted: sha256: | ||
| </ | </ | ||
| - | ====1.14 - Accèder aux Services d'un Conteneur de l' | + | ====8.3 - DCT et la commande docker push==== |
| - | Installez le navigateur texte **lynx** : | + | Pour envoyer l' |
| < | < | ||
| - | root@debian9:~# apt-get install lynx | + | root@manager:~# docker image tag alpine:latest < |
| - | Lecture des listes de paquets... Fait | + | |
| - | 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' | + | |
| - | 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 | + | L' |
| < | < | ||
| - | root@debian9:~# lynx --dump http:// | + | root@manager:~# docker image ls |
| - | Welcome to nginx! | + | REPOSITORY |
| + | ubuntu | ||
| + | nginx | ||
| + | < | ||
| + | alpine | ||
| + | mysql latest | ||
| + | centos | ||
| + | </ | ||
| - | If you see this page, the nginx web server is successfully installed | + | Lors du push vers le registry privé, il faut créer des passphrases pour **deux** clefs : |
| - | and working. Further configuration is required. | + | |
| - | For online documentation and support please refer to [1]nginx.org. | + | * 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**, |
| - | Commercial support is available at [2]nginx.com. | + | * la **repository** key aussi connue sous le nom **tagging** key (ID 168c754), utilisée pour signer l' |
| - | | + | < |
| + | root@manager: | ||
| + | The push refers to repository [docker.io/< | ||
| + | 77cae8ab23bf: | ||
| + | alpine: digest: sha256: | ||
| + | Signing and pushing trust metadata | ||
| + | You are about to create a new root signing key passphrase. This passphrase | ||
| + | will be used to protect the most sensitive key in your signing system. Please | ||
| + | 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 | ||
| + | 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/< | ||
| + | </ | ||
| - | Références | + | Les clefs sont stockées dans le répertoire **~/ |
| - | 1. http://nginx.org/ | + | < |
| - | 2. http://nginx.com/ | + | root@manager: |
| + | total 8 | ||
| + | drwx------ 2 root root 4096 nov. 10 14:49 private | ||
| + | drwx------ 3 root root 4096 nov. 8 13:48 tuf | ||
| + | |||
| + | root@manager:~# ls -l ~/.docker/trust/ | ||
| + | total 8 | ||
| + | -rw------- 1 root root 447 nov. 10 14:49 168c754ea8f36ce7fbcbe2299b6d91fc0f4d594c9ed9b86916687b618d8438ac.key | ||
| + | -rw------- 1 root root 416 nov. 10 14:49 192fc7ed9543ad4bceec58886ab1d605b7433c35f7462d7343d0780d8fddf1db.key | ||
| + | root@manager: | ||
| + | -----BEGIN ENCRYPTED PRIVATE KEY----- | ||
| + | gun: docker.io/ | ||
| + | role: targets | ||
| + | |||
| + | MIHuMEkGCSqGSIb3DQEFDTA8MBsGCSqGSIb3DQEFDDAOBAhm7HwR0y8FFAICCAAw | ||
| + | HQYJYIZIAWUDBAEqBBC729tU73wKHFQSbmZ1EVZaBIGgmGiFSs4lM5tElSGukl1B | ||
| + | HrELT9aFooFgW7oSXNLM8aFfF/vJ+BSjsgfqWLdvuH+DUXXdUidxcoGMEWnVZNIC | ||
| + | 3m40g3MywHilW4rUcjoHVTTUXABGXUQ3f7h+nI15CXcZ11qRLyWbf2uywE9yYH9O | ||
| + | M7GLUcE+pTENJKfZAhRGBEL+LgXNfGI1aAVqaEbBDcDnKKf4Uj1Xu4oLJ7je8+nT | ||
| + | dg== | ||
| + | -----END ENCRYPTED PRIVATE KEY----- | ||
| + | |||
| + | root@manager: | ||
| + | -----BEGIN ENCRYPTED PRIVATE KEY----- | ||
| + | role: root | ||
| + | |||
| + | MIHuMEkGCSqGSIb3DQEFDTA8MBsGCSqGSIb3DQEFDDAOBAiAtCzEar3AhgICCAAw | ||
| + | HQYJYIZIAWUDBAEqBBAO7hHWVoqOo6xcETQQDXRdBIGgPUoLzTz07Ajx8K3D8+Vv | ||
| + | 2NUiflMYhH/ | ||
| + | V2BwSlXp7t1Cnqp/ | ||
| + | KREO8uEq3v7HcSBBqFm0+TU+92d7hVuDApPaj0lZYP+3f7H6AjUOqu6hUoK8Ck/ | ||
| + | Ig== | ||
| + | -----END ENCRYPTED PRIVATE KEY----- | ||
| </ | </ | ||
| - | ====1.15 - Arrêter | + | ====8.4 - DCT et la commande docker build==== |
| - | Arrêtez le conteneur nginx : | + | L' |
| < | < | ||
| - | root@debian9:~# docker ps -a | + | root@manager:~# mkdir nottrusted |
| - | CONTAINER ID IMAGE | + | |
| - | aabb064d4b0a | + | root@manager:~# cd nottrusted/ |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | root@manager:~/nottrusted# vi Dockerfile |
| - | root@debian9:~# docker stop aabb | + | |
| - | aabb | + | root@manager:~/nottrusted# cat Dockerfile |
| - | root@debian9:~# docker | + | FROM docker/ |
| - | CONTAINER ID IMAGE | + | RUN echo |
| - | aabb064d4b0a | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| </ | </ | ||
| - | Démarrez | + | Lors du build de l' |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/nottrusted# docker |
| - | aabb | + | Sending build context to Docker |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | error during connect: Post http:// |
| - | aabb064d4b0a | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| </ | </ | ||
| - | ====1.16 | + | L' |
| - | + | ||
| - | Utilisez un signal pour tuer le processus du conteneur | + | |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/nottrusted# docker |
| - | aabb | + | Sending build context to Docker daemon |
| - | root@debian9:~# docker | + | Step 1/2 : FROM docker/ |
| - | CONTAINER ID IMAGE | + | latest: Pulling from docker/ |
| - | aabb064d4b0a | + | Image docker.io/ |
| - | 4f157e179134 | + | aac0c133338d: |
| - | 04b5ab87539a | + | a3ed95caeb02: |
| + | Digest: sha256: | ||
| + | Status: Downloaded newer image for docker/ | ||
| + | ---> cc7629d1331a | ||
| + | Step 2/2 : RUN echo | ||
| + | ---> Running in 694e79d3cd88 | ||
| + | |||
| + | Removing intermediate container 694e79d3cd88 | ||
| + | | ||
| + | Successfully built 686e85ee76b8 | ||
| + | Successfully tagged < | ||
| </ | </ | ||
| - | Redémarrez un conteneur en cours : | + | Lors du push de l' |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/nottrusted# docker |
| - | aabb | + | The push refers to repository [docker.io/< |
| - | root@debian9: | + | 5f70bf18a086: |
| - | CONTAINER ID IMAGE | + | c22f7bc058a9: |
| - | aabb064d4b0a | + | nottrusted: digest: sha256:1183c62a5d31e202b5f5f528e9e7cdc36140aa3212c938e1d471c6b3b59f01bc size: 734 |
| - | 4f157e179134 | + | Signing and pushing trust metadata |
| - | 04b5ab87539a | + | Enter passphrase for repository key with ID 168c754: fenestros |
| - | root@debian9:~# docker restart aabb | + | Successfully signed |
| - | aabb | + | |
| - | root@debian9:~# docker | + | |
| - | CONTAINER ID IMAGE | + | |
| - | aabb064d4b0a | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| </ | </ | ||
| - | ====1.17 - Forcer | + | <WRAP center round important 50%> |
| + | **Important** : Notez l' | ||
| + | </ | ||
| - | Supprimez | + | ===Créer |
| + | |||
| + | Par contre | ||
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/nottrusted# docker |
| - | Error response from daemon: You cannot remove a running container aabb064d4b0ade1f19216b6174631fa32a2053f6aa9d59bd724ea90ce534b004. Stop the container before attempting removal or force remove | + | |
| - | root@debian9:~# docker | + | root@manager:~/nottrusted# docker |
| - | CONTAINER | + | REPOSITORY |
| - | aabb064d4b0a | + | < |
| - | 4f157e179134 | + | < |
| - | 04b5ab87539a | + | ubuntu |
| - | root@debian9:~# docker | + | nginx |
| - | aabb | + | < |
| - | root@debian9:~# docker | + | alpine |
| - | CONTAINER | + | mysql latest |
| - | 4f157e179134 | + | centos |
| - | 04b5ab87539a | + | docker/ |
| + | |||
| + | root@manager:~/nottrusted# docker | ||
| + | The push refers to repository [docker.io/< | ||
| + | 5f70bf18a086: Mounted from < | ||
| + | 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/< | ||
| </ | </ | ||
| - | ===1.18 - Utilisation Simple | + | <WRAP center round important 50%> |
| + | **Important** : Notez la création d'une deuxième repositry key (ID 7b13d02 au lieu de ID 168c754) lors du push de l' | ||
| + | </ | ||
| - | Créez le fichier index.html et placez-le | + | La présence de cette deuxième repositry key (**7b13d02d74264624fb201e7ae13ae694286b9f761aa86adddefd0408c7234a58.key**) peut être constatée |
| < | < | ||
| - | root@debian9:~# mkdir /root/www | + | root@manager:~/nottrusted# ls -l ~/.docker/ |
| - | root@debian9:~# vi index.html | + | total 12 |
| - | root@debian9:~# cat index.html | + | -rw------- 1 root root 447 nov. 10 14:49 168c754ea8f36ce7fbcbe2299b6d91fc0f4d594c9ed9b86916687b618d8438ac.key |
| - | < | + | -rw------- 1 root root 416 nov. 10 14:49 192fc7ed9543ad4bceec58886ab1d605b7433c35f7462d7343d0780d8fddf1db.key |
| - | < | + | -rw------- 1 root root 451 nov. 10 17:37 7b13d02d74264624fb201e7ae13ae694286b9f761aa86adddefd0408c7234a58.key |
| - | < | + | |
| - | </ | + | |
| - | </ | + | |
| - | root@debian9:~# mv index.html www/ | + | |
| </ | </ | ||
| - | Indiquez au conteneur que son répertoire **/ | + | En inspectant les clefs des images créées, l' |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~/nottrusted# docker |
| - | c080793965de8a6a60db212d7e4d96de84b55352c224c054dced75b409e39bf2 | + | [ |
| - | root@debian9:~# lynx --dump http://localhost:81 | + | { |
| - | | + | " |
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | "Repo Admin" | ||
| + | ] | ||
| + | } | ||
| + | ], | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | ] | ||
| + | root@manager:~/nottrusted# docker trust inspect < | ||
| + | [ | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | "Repo Admin" | ||
| + | ] | ||
| + | } | ||
| + | ], | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | ] | ||
| + | </ | ||
| + | <WRAP center round important 50%> | ||
| + | **Important** : Notez que les clefs utilisées sont les mêmes pour les deux images. | ||
| + | </ | ||
| - | root@debian9:~# | + | < |
| + | root@manager:~/nottrusted# docker trust inspect < | ||
| + | [ | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | "Repo Admin" | ||
| + | ] | ||
| + | } | ||
| + | ], | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | ] | ||
| </ | </ | ||
| - | <WRAP center round important> | + | <WRAP center round important |
| - | **Important** | + | **Important** |
| </ | </ | ||
| - | ====1.19 - Télécharger | + | ===Supprimer |
| - | Téléchargez l' | + | Dernièrement il est possible de supprimer la signature d'une image avec la commande **docker trust revoke** |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~# docker |
| - | Using default tag: latest | + | Enter passphrase for repository key with ID 168c754: |
| - | latest: Pulling from library/centos | + | Successfully deleted signature for < |
| - | 8ba884070f61: Pull complete | + | root@manager: |
| - | Digest: sha256:8d487d68857f5bc9595793279b33d082b03713341ddec91054382641d14db861 | + | [ |
| - | Status: Downloaded newer image for centos:latest | + | { |
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | ] | ||
| </ | </ | ||
| - | Vérifiez | + | <WRAP center round important 50%> |
| + | **Important** : Il existe un autre mécanisme de signatures cryptographiques qui permet de certifier | ||
| + | </ | ||
| + | |||
| + | =====LAB #9 - Sécurisation du Socket du Daemon Docker===== | ||
| + | |||
| + | Par défaut le daemon Docker peut être contacté en utilisant un socket Unix local ce qui implique qu'il faut une connexion SSH vers l'hôte Docker. Docker peut cependant utiliser un socket http. | ||
| + | |||
| + | Pour pouvoir contacter de daemon Docker via le réseau d'une manière sécurisée il faut installer, configurer et activer le support TLS grâce aux options **tlsverify** et **tlscacert**. | ||
| + | |||
| + | La configuration implique que : | ||
| + | |||
| + | * pour le daemon Docker, seules les connections | ||
| + | * pour le client, il ne peut que connecter aux serveurs ayant un certificat signé par le CA du serveur. | ||
| + | |||
| + | La mise en place nécessite **openssl** | ||
| < | < | ||
| - | root@debian9:~# docker run -it centos bash | + | root@manager:~# which openssl |
| - | [root@86252a3f00f4 | + | /usr/bin/openssl |
| - | 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' | + | ====9.1 - Création du Certificat de l'Autorité de Certification==== |
| - | Arretez le conteneur. Démarrez | + | Commencez par créer une clef privée **ca-key.pem** pour le CA : |
| < | < | ||
| - | [root@86252a3f00f4 /]# exit | + | root@manager:~# openssl genrsa -aes256 -out ca-key.pem 4096 |
| - | exit | + | Generating RSA private key, 4096 bit long modulus |
| - | root@debian9:~# docker ps -a | + | ......................................................................................................................++++ |
| - | CONTAINER ID IMAGE | + | ...............................................................................................................................................................++++ |
| - | 86252a3f00f4 | + | e is 65537 (0x010001) |
| - | c080793965de | + | Enter pass phrase for ca-key.pem: |
| - | 4f157e179134 | + | Verifying - Enter pass phrase for ca-key.pem: |
| - | 04b5ab87539a | + | </ |
| - | root@debian9:~# docker start 8625 | + | |
| - | 8625 | + | Ensuite, créez le certificat **ca.pem** du CA : |
| - | root@debian9:~# docker attach 8625 | + | |
| - | [root@86252a3f00f4 /]# ls | + | < |
| - | anaconda-post.log bin dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | root@manager:~# openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem |
| - | [root@86252a3f00f4 /]# | + | Enter pass phrase for ca-key.pem: |
| + | You are about to be asked to enter information that will be incorporated | ||
| + | into your certificate request. | ||
| + | What you are about to enter is what is called | ||
| + | There are quite a few fields but you can leave some blank | ||
| + | For some fields there will be a default value, | ||
| + | If you enter '.', the field will be left blank. | ||
| + | ----- | ||
| + | Country Name (2 letter code) [AU]:GB | ||
| + | State or Province Name (full name) [Some-State]: | ||
| + | Locality Name (eg, city) []:ADDLESTONE | ||
| + | Organization Name (eg, company) [Internet Widgits Pty Ltd]:I2TCH LIMITED | ||
| + | Organizational Unit Name (eg, section) | ||
| + | Common Name (e.g. server FQDN or YOUR name) []: | ||
| + | Email Address | ||
| </ | </ | ||
| - | ====1.21 - Installer un logiciel dans le conteneur=== | + | ====9.2 - Création du Certificat du Serveur Hôte du Daemon Docker==== |
| - | Créez le fichier | + | Les clefs du CA ayant été créées, créez une clef **server-key.pem** pour le serveur hôte du daemon Docker |
| < | < | ||
| - | [root@86252a3f00f4 /]# vi / | + | root@manager:~# openssl genrsa |
| - | [root@86252a3f00f4 /]# cat /etc/yum.repos.d/ | + | Generating RSA private key, 4096 bit long modulus |
| - | [mongodb-org-4.2] | + | .................................................................................................................................++++ |
| - | name=MongoDB Repository | + | ...........................++++ |
| - | baseurl=https:// | + | e is 65537 (0x010001) |
| - | gpgcheck=1 | + | |
| - | enabled=1 | + | |
| - | gpgkey=https:// | + | |
| - | [root@86252a3f00f4 /]# | + | |
| </ | </ | ||
| - | Installez mongo : | + | Créez ensuite un **[[https:// |
| < | < | ||
| - | [root@86252a3f00f4 /]# yum install | + | root@manager:~# echo $HOSTNAME |
| + | manager.i2tch.loc | ||
| + | root@manager: | ||
| </ | </ | ||
| - | Démarrez mongod | + | Une connexion TLS peut être effectuée en utilisant un FQDN ou une adresse IP. Pour cette raison, créez le fichier **extfile.cnf** |
| < | < | ||
| - | [root@86252a3f00f4 /]# mongod --config /etc/mongod.conf & | + | root@manager:~# echo subjectAltName = DNS:`echo $HOSTNAME`, |
| - | [1] 82 | + | </code> |
| - | [root@86252a3f00f4 | + | |
| - | forked process: 84 | + | |
| - | child process started successfully, | + | |
| - | [1]+ Done mongod --config / | + | Fixez l' |
| - | [root@86252a3f00f4 /]# | + | |
| + | < | ||
| + | root@manager:~# echo extendedKeyUsage = serverAuth >> extfile.cnf | ||
| </ | </ | ||
| - | Vérifiez que mongod est démarré | + | Vérifiez que votre fichier a été correctement créé |
| < | < | ||
| - | [root@86252a3f00f4 /]# ps aux | + | root@manager:~# cat extfile.cnf |
| - | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | + | subjectAltName = DNS:manager.i2tch.loc,IP:10.0.2.62,IP:127.0.0.1 |
| - | root | + | extendedKeyUsage = serverAuth |
| - | root 84 1.2 | + | |
| - | root | + | |
| </ | </ | ||
| - | Utilisez | + | Signez maintenant |
| < | < | ||
| - | [root@86252a3f00f4 /]# mongo | + | root@manager:~# openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem -extfile extfile.cnf |
| - | MongoDB shell version: 4.2.2 | + | Signature ok |
| - | connecting to: test | + | subject=CN = manager.i2tch.loc |
| - | Welcome to the MongoDB shell. | + | Getting CA Private Key |
| - | For interactive help, type " | + | Enter pass phrase for ca-key.pem:fenestros |
| - | For more comprehensive documentation, | + | |
| - | http:// | + | |
| - | Questions? Try the support group | + | |
| - | http:// | + | |
| - | Server has startup warnings: | + | |
| - | 2019-04-09T17: | + | |
| - | 2019-04-09T17: | + | |
| - | > | + | |
| </ | </ | ||
| - | Sortez de mongo et du conteneur | + | ====9.3 - Création |
| + | |||
| + | Créez ensuite la clef privée **key.pem** du client qui se connectera au daemon à partir du réseau | ||
| < | < | ||
| - | > exit | + | root@manager:~# openssl genrsa -out key.pem 4096 |
| - | bye | + | Generating RSA private key, 4096 bit long modulus |
| - | [root@86252a3f00f4 /]# exit | + | ...................................................................................................................................++++ |
| - | exit | + | ...............++++ |
| - | root@debian9: | + | e is 65537 (0x010001) |
| </ | </ | ||
| - | ====1.22 - Utilisation de la commande docker commit==== | + | Modifiez l' |
| - | Créez | + | < |
| + | root@manager: | ||
| + | root@manager: | ||
| + | 127.0.0.1 localhost | ||
| + | 10.0.2.46 debian11.i2tch.loc debian11 | ||
| + | 10.0.2.45 myregistry.i2tch.loc | ||
| + | 10.0.2.62 manager.i2tch.loc manager | ||
| + | 10.0.2.63 worker1.i2tch.loc worker1 | ||
| + | 10.0.2.64 worker2.i2tch.loc worker2 | ||
| + | |||
| + | # The following lines are desirable for IPv6 capable hosts | ||
| + | ::1 | ||
| + | ff02::1 ip6-allnodes | ||
| + | ff02::2 ip6-allrouters | ||
| + | </ | ||
| + | |||
| + | Créez | ||
| < | < | ||
| - | root@debian9:~# docker ps -a | + | root@manager:~# openssl req -subj '/ |
| - | CONTAINER ID IMAGE | + | |
| - | 86252a3f00f4 | + | |
| - | c080793965de | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | root@debian9: | + | |
| - | sha256: | + | |
| </ | </ | ||
| - | Supprimez le conteneur utilisé pour créer | + | Fixez l'attribut étendu de l' |
| < | < | ||
| - | root@debian9:~# docker rm 8625 | + | root@manager:~# echo extendedKeyUsage = clientAuth > extfile-client.cnf |
| - | 8625 | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | c080793965de | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| </ | </ | ||
| - | Utilisez | + | Signez le CSR du client **client.csr** avec la clef privée du CA **ca-key.pem** afin de créer le certificat du client |
| < | < | ||
| - | root@debian9:~# docker run -it --name mongo i2tch/ | + | root@manager:~# openssl x509 -req -days 365 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile extfile-client.cnf |
| - | [root@d20fb56a38b0 /]# ls / | + | Signature ok |
| - | / | + | subject=CN = myregistry.i2tch.loc |
| - | / | + | Getting CA Private Key |
| - | [root@d20fb56a38b0 /]# ps aux | + | Enter pass phrase for ca-key.pem:fenestros |
| - | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | + | |
| - | root | + | |
| - | root 15 0.0 0.1 51748 3468 pts/0 R+ | + | |
| </ | </ | ||
| - | Editez le fichier / | + | Vérifiez la présence des fichiers générés |
| < | < | ||
| - | [root@d20fb56a38b0 /]# echo "/ | + | root@manager:~# ls -l |
| - | [root@d20fb56a38b0 /]# tail /etc/bashrc | + | total 60 |
| - | . " | + | -rw------- 1 root root 3326 nov. 11 10:53 ca-key.pem |
| - | fi | + | -rw-r--r-- 1 root root 2163 nov. 11 10:57 ca.pem |
| - | fi | + | -rw-r--r-- 1 root root 17 nov. 11 11:15 ca.srl |
| - | done | + | -rw-r--r-- 1 root root 1907 nov. 11 11:15 cert.pem |
| + | -rw-r--r-- 1 root root 1594 nov. 11 11:12 client.csr | ||
| + | drwxr-xr-x 5 root root 4096 nov. 8 12:58 docker-bench-security | ||
| + | -rw-r--r-- 1 root root 1707 nov. 8 12:35 docker-stack.yml | ||
| + | -rw-r--r-- 1 root root 30 nov. 11 11:13 extfile-client.cnf | ||
| + | -rw-r--r-- 1 root root 95 nov. 11 11:06 extfile.cnf | ||
| + | -rw------- 1 root root 3243 nov. 11 11:10 key.pem | ||
| + | drwxr-xr-x 2 root root 4096 nov. 10 17:21 nottrusted | ||
| + | -rw-r--r-- 1 root root 1964 nov. 11 11:08 server-cert.pem | ||
| + | -rw-r--r-- 1 root root 1594 nov. 11 11:01 server.csr | ||
| + | -rw------- 1 root root 3243 nov. 11 10:59 server-key.pem | ||
| + | -rw-r--r-- 1 root root 882 oct. 27 15:46 stats | ||
| + | </ | ||
| - | unset i | + | Supprimez les fichiers ayant déjà été utilisés, à savoir les deux CSR et les deux fichiers des extensions : |
| - | unset -f pathmunge | + | |
| - | fi | + | < |
| - | # vim:ts=4:sw=4 | + | root@manager:~# rm -v client.csr server.csr extfile.cnf extfile-client.cnf |
| - | / | + | ' |
| + | ' | ||
| + | ' | ||
| + | ' | ||
| </ | </ | ||
| - | Consultez la liste des conteneurs et relevez le CONTAINER ID du conteneur **mongo** | + | Modifiez les permissions |
| < | < | ||
| - | [root@d20fb56a38b0 /]# exit | + | root@manager:~# chmod -v 0400 ca-key.pem key.pem server-key.pem |
| - | exit | + | le mode de ' |
| - | root@debian9:~# docker ps -a | + | le mode de 'key.pem' a été modifié de 0600 (rw-------) en 0400 (r--------) |
| - | CONTAINER ID IMAGE | + | le mode de ' |
| - | d20fb56a38b0 | + | |
| - | c080793965de | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| </ | </ | ||
| - | Utilisez la commande commit pour " | + | Ainsi que les permissions des certificats |
| < | < | ||
| - | root@debian9:~# docker commit d20f i2tch/ | + | root@manager:~# chmod -v 0444 ca.pem server-cert.pem cert.pem |
| - | sha256: | + | le mode de ' |
| + | le mode de ' | ||
| + | le mode de ' | ||
| </ | </ | ||
| - | Démarrez de nouveau | + | Arrêtez et supprimez |
| < | < | ||
| - | root@debian9:~# docker | + | root@manager:~# docker |
| - | d20f | + | mysql |
| - | root@debian9:~# docker | + | root@manager:~# docker |
| - | CONTAINER ID IMAGE | + | mysql |
| - | c080793965de | + | </code> |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | root@debian9: | + | |
| - | [root@bcec3f27ed58 /]# about to fork child process, waiting until server is ready for connections. | + | |
| - | forked process: 16 | + | |
| - | child process started successfully, | + | |
| - | [1]+ Done / | + | ====9.4 |
| - | [root@bcec3f27ed58 /]# ps aux | + | |
| - | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | + | Arrêtez et désactivez le service Docker : |
| - | root | + | |
| - | root 16 2.0 2.4 298788 49276 ? Sl | + | < |
| - | root 39 0.0 0.1 51748 3476 pts/0 R+ 17:27 0:00 ps aux | + | root@manager:~# systemctl stop docker |
| - | [root@bcec3f27ed58 | + | Warning: Stopping docker.service, |
| + | | ||
| + | root@manager:~# systemctl disable docker | ||
| + | Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install. | ||
| + | Executing: /lib/ | ||
| </ | </ | ||
| - | ====1.23 - Se connecter au serveur du conteneur | + | Lancez un invocation directe |
| - | Pour pouvoir se connecter à mongodb depuis la machine hôte, il convient d' | + | < |
| + | root@manager: | ||
| + | [1] 1868 | ||
| + | root@manager: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | WARN[2019-11-11T12: | ||
| + | WARN[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | INFO[2019-11-11T12: | ||
| + | [Entrée] | ||
| + | root@manager: | ||
| + | </ | ||
| + | |||
| + | Vérifiez que le processus tourne | ||
| < | < | ||
| - | [root@bcec3f27ed58 /]# vi / | + | root@manager:~# ps aux | grep docker |
| - | [root@bcec3f27ed58 /]# cat / | + | root 1868 0.2 4.0 421876 82236 pts/0 Sl |
| - | bindIp: 0.0.0.0 | + | root 1995 0.0 0.0 12780 964 pts/0 S+ |
| </ | </ | ||
| - | Sortez du conteneur, re-créez une image, supprimez | + | Installez |
| < | < | ||
| - | [root@bcec3f27ed58 /]# exit | + | root@manager:~# apt install |
| - | exit | + | </code> |
| - | root@debian9:~# docker commit mongo i2tch/ | + | |
| - | sha256: | + | |
| - | root@debian9: | + | |
| - | mongo | + | |
| - | root@debian9: | + | |
| - | [root@d2ddb4f8ca8a | + | |
| - | forked process: 16 | + | |
| - | [root@d2ddb4f8ca8a /]# child process started successfully, | + | |
| - | [1]+ Done / | + | Vérifiez que le port **2376** est à l' |
| - | [root@d2ddb4f8ca8a | + | |
| + | < | ||
| + | root@manager:~# netstat -anp | grep 2376 | ||
| + | tcp6 | ||
| </ | </ | ||
| - | Dans votre machine hôte, configurez | + | ====9.5 - Configuration du Client==== |
| + | |||
| + | Transférez ensuite | ||
| < | < | ||
| - | [root@f5b45072b831 /]# exit | + | root@manager:~# scp ca.pem |
| - | root@debian9:~# | + | The authenticity of host '10.0.2.45 (10.0.2.45)' can't be established. |
| - | root@debian9: | + | ECDSA key fingerprint is SHA256:sEfHBv9azmK60cjqF/ |
| - | root@debian9: | + | Are you sure you want to continue connecting (yes/no)? yes |
| - | root@debian9: | + | Warning: Permanently added '10.0.2.45' (ECDSA) to the list of known hosts. |
| - | Executing: / | + | trainee@10.0.2.45's password: trainee |
| - | gpg: key 68818C72E52529D4: | + | ca.pem |
| - | gpg: Total number processed: 1 | + | key.pem 100% 3243 3.0MB/s 00:00 |
| - | gpg: | + | cert.pem |
| - | root@debian9:~# | + | |
| - | root@debian9: | + | |
| - | deb http://repo.mongodb.org/apt/debian stretch/ | + | |
| - | root@debian9:~# | + | |
| - | root@debian9:~# apt-get update | + | |
| </ | </ | ||
| - | Cette fois, installez uniquement le client de mongodb | + | Lancez la commande **docker version** sur la VM **10.0.2.45** |
| < | < | ||
| - | root@debian9:~# apt-get install mongodb-org-shell | + | trainee@myregistry:~$ docker |
| - | Lecture des listes de paquets... Fait | + | Client: Docker Engine |
| - | Construction de l' | + | Version: |
| - | Lecture des informations d' | + | API version: |
| - | Les NOUVEAUX paquets suivants seront installés : | + | Go version: |
| - | | + | Git commit: |
| - | 0 mis à jour, 1 nouvellement installés, 0 à enlever et 95 non mis à jour. | + | Built: Fri Oct 18 15:52:34 2019 |
| - | Il est nécessaire de prendre 9 809 ko dans les archives. | + | OS/Arch: linux/amd64 |
| - | 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) | + | Server: Docker Engine |
| - | 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.) | + | Version: |
| - | Préparation du dépaquetage de .../mongodb-org-shell_4.0.8_amd64.deb ... | + | API version: |
| - | Dépaquetage de mongodb-org-shell (4.0.8) ... | + | Go version: |
| - | Paramétrage de mongodb-org-shell (4.0.8) ... | + | Git commit: |
| - | Traitement des actions différées (« triggers ») pour man-db (2.7.6.1-2) ... | + | Built: |
| + | OS/Arch: linux/ | ||
| + | Experimental: | ||
| + | | ||
| + | Version: | ||
| + | | ||
| + | | ||
| + | Version: | ||
| + | GitCommit: | ||
| + | docker-init: | ||
| + | Version: | ||
| + | | ||
| </ | </ | ||
| - | Notez qu' | + | Afin de faciliter l'utilisation des commandes sur le serveur |
| < | < | ||
| - | root@debian9:~# docker | + | trainee@myregistry:~$ mkdir -pv ~/.docker |
| - | " | + | mkdir: création du répertoire '/ |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| </ | </ | ||
| - | Démarrez donc le conteneur et cherchez l' | + | Copiez ensuite les fichiers *.pem dans le répertoire **~/ |
| < | < | ||
| - | root@debian9:~# docker | + | trainee@myregistry:~$ cp -v {ca, |
| - | mongo | + | ' |
| - | root@debian9: | + | 'cert.pem' -> '/ |
| - | " | + | 'key.pem' -> '/ |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| </ | </ | ||
| - | Connectez-vous maintenant à votre mongodb à partir de la machine hôte : | + | Créez les deux variables **DOCKER_HOST** et **DOCKER_TLS_VERIFY** |
| < | < | ||
| - | root@debian9:~# mongo --host 172.17.0.3 | + | trainee@myregistry:~$ export DOCKER_HOST=tcp://manager.i2tch.loc:2376 DOCKER_TLS_VERIFY=1 |
| - | MongoDB shell version v4.0.8 | + | </ |
| - | connecting to: mongodb://172.17.0.3:27017/? | + | |
| - | WARNING: No implicit session: Logical Sessions are only supported on server versions 3.6 and greater. | + | Maintenant la connexion est sécurisée par défaut |
| - | Implicit session: dummy session | + | |
| - | MongoDB server version: 4.2.2 | + | < |
| - | WARNING: shell and server versions do not match | + | trainee@myregistry: |
| - | Welcome to the MongoDB shell. | + | REPOSITORY |
| - | For interactive help, type " | + | i2tch/docker |
| - | For more comprehensive documentation, | + | i2tch/otherimage |
| - | http://docs.mongodb.org/ | + | ubuntu |
| - | Questions? Try the support group | + | nginx |
| - | http://groups.google.com/ | + | alpine |
| - | Server has startup warnings: | + | i2tch/ |
| - | 2019-04-09T17: | + | mysql |
| - | 2019-04-09T17: | + | centos |
| - | > | + | docker/ |
| </ | </ | ||
| ----- | ----- | ||
| - | < | + | Copyright © 2025 Hugh NORRIS |
| - | <div align=" | + | |
| - | Copyright © 2021 Hugh Norris | + | |
| - | </ | + | |
| - | </ | + | |