Ejecutar Contenedores
Ejemplo de configuración
El siguiente fragmento de configuración de Butane configura el hello.service de systemd para ejecutar busybox.
Es posible que pueda usar referencias de archivos locales a unidades systemd en lugar de insertarlas en línea. Consulte Uso del parámetro --files-dir de butane para insertar archivos para más información.
|
Ejemplo de ejecución de busybox usando systemd y podman
variant: fcos
version: 1.6.0
systemd:
units:
- name: hello.service
enabled: true
contents: |
[Unit]
Description=MiApli
After=network-online.target
Wants=network-online.target
[Service]
TimeoutStartSec=0
ExecStartPre=-/bin/podman kill busybox1
ExecStartPre=-/bin/podman rm busybox1
ExecStartPre=/bin/podman pull busybox
ExecStart=/bin/podman run --name busybox1 busybox /bin/sh -c "trap 'exit 0' INT TERM; while true; do echo Hello World; sleep 1; done"
[Install]
WantedBy=multi-user.target
Ejemplo para ejecutar cajas ocupadas utilizando Podman Quadlet
Podman Quadlet es una funcionalidad incluida en podman que concede iniciar contenedores por medio de systemd utilizando un generador de systemd. El ejemplo a continuación es lo mismo que hello.service fue mostrado anteriormente pero desplegado por medio de la funcionalidad Podman Quadlet.
variant: fcos
version: 1.6.0
storage:
files:
- path: /etc/containers/systemd/hello.container
contents:
inline: |
[Unit]
Description=Hello Service
Wants=network-online.target
After=network-online.target
[Container]
ContainerName=busybox1
Image=docker.io/busybox
Exec=/bin/sh -c "trap 'exit 0' INT TERM; while true; do echo Hello World; sleep 1; done"
[Install]
WantedBy=multi-user.target
Ejecutar etcd
etcd no está incluido como parte de Fedora CoreOS. Para usarlo, ejecútelo como contenedor, como se muestra a continuación.
Butane config for setting up single node etcd
variant: fcos
version: 1.6.0
systemd:
units:
- name: etcd-member.service
enabled: true
contents: |
[Unit]
Description=Run single node etcd
After=network-online.target
Wants=network-online.target
[Service]
ExecStartPre=mkdir -p /var/lib/etcd
ExecStartPre=-/bin/podman kill etcd
ExecStartPre=-/bin/podman rm etcd
ExecStartPre=-/bin/podman pull quay.io/coreos/etcd
ExecStart=/bin/podman run --name etcd --volume /var/lib/etcd:/etcd-data:z --net=host quay.io/coreos/etcd:latest /usr/local/bin/etcd --data-dir /etcd-data --name node1 \
--initial-advertise-peer-urls http://127.0.0.1:2380 --listen-peer-urls http://127.0.0.1:2380 \
--advertise-client-urls http://127.0.0.1:2379 \
--listen-client-urls http://127.0.0.1:2379 \
--initial-cluster node1=http://127.0.0.1:2380
ExecStop=/bin/podman stop etcd
[Install]
WantedBy=multi-user.target
For more information
See the etcd documentation for more information on running etcd in containers and how to set up multi-node etcd.
Want to help? Learn how to contribute to Fedora Docs ›