2025-06-06 09:56:47 +02:00

59 lines
2.1 KiB
Markdown

Pour créer un conteneur Docker avec systemd pour Ubuntu 24.04, suivez ces étapes :
1. Créez un fichier Dockerfile avec le contenu suivant :
```dockerfile
FROM ubuntu:24.04
# Installer systemd
RUN apt-get update && apt-get install -y systemd
# Configurer systemd
RUN cd /lib/systemd/system/sysinit.target.wants/ && \
ls | grep -v systemd-tmpfiles-setup | xargs rm -f $1
RUN rm -f /lib/systemd/system/multi-user.target.wants/* \
/etc/systemd/system/*.wants/* \
/lib/systemd/system/local-fs.target.wants/* \
/lib/systemd/system/sockets.target.wants/*udev* \
/lib/systemd/system/sockets.target.wants/*initctl* \
/lib/systemd/system/basic.target.wants/* \
/lib/systemd/system/anaconda.target.wants/*
# Définir le point d'entrée
ENTRYPOINT ["/lib/systemd/systemd"]
```
2. Construisez l'image Docker :
```bash
docker build -t ubuntu-24.04-systemd .
```
3. Lancez le conteneur avec les options nécessaires pour systemd :
```bash
docker run -d --name ubuntu-24.04-systemd --privileged \
--cgroupns=host \
--tmpfs /run \
--tmpfs /run/lock \
--tmpfs /tmp \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
ubuntu-24.04-systemd
```
Cette configuration permet d'exécuter un conteneur Ubuntu 24.04 avec systemd activé[3][4]. Vous pouvez maintenant utiliser ce conteneur comme base pour vos applications nécessitant systemd[7].
Citations:
[1] https://www.linuxtuto.com/how-to-install-docker-on-ubuntu-24-04/
[2] https://www.fosstechnix.com/how-to-install-docker-on-ubuntu-24-04-lts/
[3] https://jeci.fr/fr/blog/2020/0729-run-docker-with-systemd/
[4] https://github.com/trfore/docker-ubuntu2404-systemd
[5] https://www.youtube.com/watch?v=J4dZ2jcpiP0
[6] https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04-fr
[7] https://www.rosehosting.com/blog/how-to-install-docker-on-ubuntu-24-04/
[8] https://rdr-it.com/ubuntu-24-04-installation-de-docker-et-docker-compose/
[9] https://alexhost.com/fr/faq/guide-dinstallation-et-dutilisation-de-docker-sur-ubuntu/
[10] https://www.cherryservers.com/blog/install-docker-ubuntu
[11] https://www.hostinger.fr/tutoriels/installer-docker-sur-ubuntu