Table des matières
- 2026:
- 2025:
14 billet(s) pour novembre 2026
| Notes IA WebMCP | 2026/11/19 09:13 | |
| Réseaux - protocole QUIC mieux que TCP | 2026/11/17 21:26 | Jean-Baptiste |
| Notes conversion JSON YAML | 2026/11/13 11:16 | Jean-Baptiste |
| Git commit perdu | 2026/11/12 18:16 | Jean-Baptiste |
| Notes mojo lang | 2026/11/11 20:34 | Jean-Baptiste |
| Notes rust lang compilation | 2026/11/11 18:35 | Jean-Baptiste |
| Mémoire VSIZE VMSIZE SEGV lang C | 2026/11/11 15:59 | Jean-Baptiste |
| Ansible-navigator utilisation de ansible-vault | 2026/11/06 11:33 | Jean-Baptiste |
| Err Ansible - Module result deserialization failed No start of json char found | 2026/11/06 09:09 | Jean-Baptiste |
| Script Python conversion JSON vers CSV | 2026/11/06 08:14 | Jean-Baptiste |
| Filter Incoming IPv4 Packets Containing IP Options - cve-2026-98432 mitigation - Kernel TCP Use-After-Free | 2026/11/04 21:04 | Jean-Baptiste |
| Notes ZFS | 2026/11/03 18:04 | Jean-Baptiste |
| Diff image container | 2026/11/03 16:30 | Jean-Baptiste |
| Notes processus multi-thread | 2026/11/03 10:59 | Jean-Baptiste |
Docker-compose
Voir :
- podman-compose
- /usr/libexec/docker/cli-plugins/docker-compose
docker-compose.yml
version: "3.7" services: memcached: image: memcached:1.5.19-alpine container_name: pm-memcached ports: - "11211" networks: - backend restart: unless-stopped php: image: acme/app1-www:1.01.02 container_name: pm-www volumes: - src:/opt/acme/dir1/app1 - /mnt/data:/mnt/data ports: - "8000" networks: - backend restart: unless-stopped depends_on: - memcached httpd: image: acme/app1-httpd:1.01.02 container_name: pm-httpd volumes: - src:/opt/acme/dir1/app1 - /var/log/app1:/var/log/app1 ports: - "443:443" networks: - backend restart: unless-stopped depends_on: - php networks: backend: # ipam: # driver: default # config: # - subnet: 192.168.10.0/24 volumes: src:
docker-compose.yml
version: "3.7" services: webapp: build: context: . args: - http_proxy=http://192.168.56.1:3128 - https_proxy=http://192.168.56.1:3128 network_mode: "host"
docker-compose.yml
version: "3.7" services: webapp: image: webapp container_name: webapp1 network_mode: "host"
docker-compose build --no-cache
docker-compose up
Autres
volumes: - "/etc/timezone:/etc/timezone:ro" - "/etc/localtime:/etc/localtime:ro"
host-bind sur un fichier qui ne soit pas un dossier :
volumes: - type: bind read_only: True source: ./sourceFile.yaml target: /location/targetFile.yaml
Utiliser les Profiles
docker-compose.yml
--- services: app_plop: container_name: app_plop profiles: - n image: "${CTN_app_plop_IMAGE}" hostname: l12app_plop03 restart: "always" network_mode: host volumes: - {'type': 'bind', 'read_only': True, 'source': '/etc/timezone', 'target': '/etc/timezone'} - {'type': 'bind', 'read_only': True, 'source': '/etc/localtime', 'target': '/etc/localtime'} - /data/data:/home/app/data
.env
CTN_app_plop_IMAGE="registry.acme.local/repository/docker-local/app_plop:l13-p3.3.12-d10.1.2-v1.0"
docker-compose --profile='*' pull docker-compose --profile n config > docker-compose2.yml docker-compose --profile n up
Ansible
env.jinja
{% for container in containers %} CTN_{{ container.container_name }}_IMAGE="{{ container.container_image }}" {% endfor %}
docker-compose.yml.jinja
--- services: {% for container in containers %} {{ container.container_name }}: container_name: {{ container.container_name }} profiles: {%- for profile in container.profiles +%} - {{ profile }} {%- endfor +%} image: "${CTN_{{ container.container_name }}_IMAGE}" hostname: {{ container.container_hostname }} restart: "{{ container.container_restart_policy }}" network_mode: {{ container.network }} volumes: {%- for volume in container.container_mounts +%} - {{ volume }} {%- endfor +%}
- name: Template docker-compose.yml ansible.builtin.template: src: "{{ item.src }}" dest: "{{ item.dest }}" mode: "0640" loop: - {src: 'docker-compose.yml.jinja', dest: '/opt/compose/docker-compose.yml'} - {src: 'env.jinja', dest: '/opt/compose/.env'} - name: Pull images community.docker.docker_compose_v2_pull: project_src: /opt/compose/ profiles: - '*' - name: Deploy app with Docker Compose community.docker.docker_compose_v2: project_src: /opt/compose/ state: present profiles: - n
Pb
docker-compose: error while loading shared libraries: libz.so.1: failed to map segment from shared object
# mount -o remount,noexec /tmp # docker-compose docker-compose: error while loading shared libraries: libz.so.1: failed to map segment from shared object
Solution
mkdir /plop chmod 1777 /plop export TMPDIR=/plop docker-compose
Faire un wrapper
mv /usr/local/bin/docker-compose /usr/local/bin/docker-compose-bin
/usr/local/bin/docker-compose
#! /bin/bash DIR=$(dirname "$(realpath "$0")") TMPDIR=/tmp2 if [ ! -d "$TMPDIR" ] then mkdir "$TMPDIR" chmod 1777 "$TMPDIR" fi export TMPDIR ${DIR}/docker-compose-bin "$@"
Docker volume storage
Voir :
- rclone
- Container Storage Interface (CSI)
NFS
/etc/nfs.conf
[nfsd] tcp=y vers2=n vers3=n vers4=y vers4.0=y vers4.1=y vers4.2=y
systemctl restart nfs-server.service
exportfs -rav
/etc/exports
/export *(rw,sync,fsid=0,crossmnt,no_subtree_check) /export/partage *(rw,sync,nohide,insecure,no_subtree_check)
docker volume create --driver local --opt type=nfs4 --opt o=addr=172.19.0.1,rw --opt device=:/partage data-nfs docker run -ti -v data-nfs:/data debian /bin/bash
Docker Swarm
Voir :
Notes générales
Vous allez avoir besoin d'au moins trois serveurs ou machines virtuelles avec Docker d'installé
The network ports required for a Docker Swarm to function correctly are:
TCP port 2376 for secure Docker client communication. This port is required for Docker Machine to work. Docker Machine is used to orchestrate Docker hosts. TCP port 2377. This port is used for communication between the nodes of a Docker Swarm or cluster. It only needs to be opened on manager nodes. TCP and UDP port 7946 for communication among nodes (container network discovery). UDP port 4789 for overlay network traffic (container ingress networking).
ufw allow 22/tcp ufw allow 2376/tcp # Que sur le Manager ufw allow 2377/tcp ufw allow 7946/tcp ufw allow 7946/udp ufw allow 4789/udp ufw reload ufw enable systemctl restart docker
docker system info
and looking for a message Swarm: active
Sur le Manager
# docker swarm init --advertise-addr 192.168.99.121
docker swarm init
docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 192.168.99.121:2377
Voir l'état des nœuds
docker node ls
https://www.grottedubarbu.fr/introduction-docker-swarm/
$ openstack server create --image "Ubuntu 20.04" --flavor "s1-4" --key-name "MyKey" --net "Ext-Net" --user-data=docker.yaml my-manager $ openstack server create --image "Ubuntu 20.04" --flavor "s1-4" --key-name "MyKey" --net "Ext-Net" --user-data=docker.yaml my-worker1 $ openstack server create --image "Ubuntu 20.04" --flavor "s1-4" --key-name "MyKey" --net "Ext-Net" --user-data=docker.yaml my-worker2
docker-compose.yaml
version: "3" services: viz: image: dockersamples/visualizer volumes: - "/var/run/docker.sock:/var/run/docker.sock" ports: - "8080:8080"
docker stack deploy -c docker-compose.yaml visualizer
Pour vérifier que votre service fonctionne :
docker service ls
docker service ps --no-trunc visualizer docker service inspect visualizer
Registry
Voir https://docs.docker.com/engine/swarm/stack-deploy/
docker service create --name registry --publish published=5000,target=5000 registry:2
docker service ls curl http://localhost:5000/v2/
Test the app with Compose
docker-compose up
docker-compose down --volumes
Push the generated image to the registry
docker-compose push
Déinstall
docker service ls docker stack rm plop docker swarm leave --force
Autres
docker swarm update --snapshot-interval 10000 systemctl restart docker
Ansible add mount option for hardening - loop on ansible mounts
- name: add nodev mount option for all LVM mounts exept root part mount: name: '{{ item.mount }}' src: '{{ item.device }}' # UUID not needed when LVM state: mounted fstype: '{{ item.fstype }}' opts: "{{ item.options | regex_replace(',nodev',`) }},nodev" # Fix duplicate when: item.options.find("nodev") != -1 and item.device.find("mapper") != -1 and not item.mount in [ "/" ] with_items: '{{ ansible_mounts }}' - name: add nodev mount option for all non-LVM mounts exept root part mount: name: '{{ item.mount }}' src: 'UUID={{ item.uuid }}' state: mounted fstype: '{{ item.fstype }}' opts: "{{ item.options | regex_replace(',nodev',`) }},nodev" # Fix duplicate when: item.options.find("nodev") != -1 and item.device.find("mapper") == -1 and not item.mount in [ "/" ] with_items: '{{ ansible_mounts }}'
ou encore mieux
- name: add nodev mount option for all except root part mount: name: '{{ item.mount }}' # Pour les partitions non LVM, on utilise UUID, sinon on prend le device src: "{{ 'UUID=%s' % item.uuid if item.device.find('mapper') == -1 else item.device }}" state: present fstype: '{{ item.fstype }}' opts: "{{ item.options | regex_replace(',nodev',`) }},nodev" # Fix duplicate when: item.options is not search("nodev") and not item.mount in [ "/", "/var/tmp" ] with_items: '{{ ansible_mounts }}' register: nodev_mounts
Docker nproc nombre maximum de process
Docker nproc Nombre maximum de process
Erreur java.lang.OutOfMemoryError: unable to create new native thread
Exemple SystemD Docker
# CTR=`docker run --pids-limit 111 --detach --rm busybox /bin/sleep 8h`
# cat /sys/fs/cgroup/pids/system.slice/docker-${CTR}.scope/pids.max
111
# systemctl show docker-$CTR.scope | grep TasksMax
TasksMax=18446744073709551615
# systemctl disable --now postfix
# systemctl enable --now postfix
# cat /sys/fs/cgroup/pids/system.slice/docker-${CTR}.scope/pids.max
max
Exemple de configuration du daemon Dockerd
Option --default-pids-limit=-1
/etc/sysconfig/docker
# Modify these options if you want to change the way the docker daemon runs OPTIONS='--selinux-enabled --log-driver=json-file --signature-verification=false --default-pids-limit=-1'
Diag sur OpenShift
# oc debug node/$NODE_NAME # chroot /host # cgroup=$(awk -F: '/:pids:/{print $3}' /proc/self/cgroup) # cat /sys/fs/cgroup/pids/"${cgroup}"/pids.max 4096
Exemple de création de conteneur
sudo docker create --name bankapp-inst -it \ --sysctl fs.mqueue.msg_max=10000 \ --sysctl fs.mqueue.msgsize_max=1049600 \ --sysctl fs.mqueue.queues_max=10000 \ --ulimit msgqueue=-1 \ --ulimit nproc=256:512 \ bankapp
