Instalação no OracleLinux 8
Preparando a vm
Preparando uma partição exclusiva para os containers
$ sudo pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
$ sudo pvdisplay /dev/sdb
"/dev/sdb" is a new physical volume of "32,00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 32,00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID GVq88k-0f2q-kN15-aH3d-iFc5-ONL0-Heqd65
$ sudo pvs /dev/sdb
PV VG Fmt Attr PSize PFree
/dev/sdb lvm2 --- 32,00g 32,00g
$ sudo vgcreate VGcontainers /dev/sdb
Volume group "VGcontainers" successfully created
$ sudo vgdisplay VGcontainers
--- Volume group ---
VG Name VGcontainers
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size <32,00 GiB
PE Size 4,00 MiB
Total PE 8191
Alloc PE / Size 0 / 0
Free PE / Size 8191 / <32,00 GiB
VG UUID ICsUjz-MYdl-JVqo-W5gL-ICfR-MkiK-lnYKAU
$ sudo vgs VGcontainers
VG #PV #LV #SN Attr VSize VFree
VGcontainers 1 0 0 wz--n- <32,00g <32,00g
$ sudo lvcreate -l 100%FREE -n LVcontainers VGcontainers
Logical volume "LVcontainers" created.
$ sudo lvdisplay /dev/VGcontainers/LVcontainers
--- Logical volume ---
LV Path /dev/VGcontainers/LVcontainers
LV Name LVcontainers
VG Name VGcontainers
LV UUID SPTgNy-LXj7-KFWo-EcPC-bcrt-MsFO-1MD9kX
LV Write Access read/write
LV Creation host, time pa-mba-vm-01.juntotelecom.com.br, 2022-05-21 14:44:13 -0300
LV Status available
# open 0
LV Size <32,00 GiB
Current LE 8191
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:6
$ sudo lvs /dev/VGcontainers/LVcontainers
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
LVcontainers VGcontainers -wi-a----- <32,00g
$ sudo mkfs.xfs /dev/mapper/VGcontainers-LVcontainers
meta-data=/dev/mapper/VGcontainers-LVcontainers isize=512 agcount=4, agsize=2096896 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=0 inobtcount=0
data = bsize=4096 blocks=8387584, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=4095, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
$ sudo mkdir /var/lib/containers
$ UUID=`sudo blkid -o export /dev/mapper/VGcontainers-LVcontainers | grep UUID`
$ sudo cp -p /etc/fstab{,.dist}
$ echo "${UUID} /var/lib/containers xfs defaults 1 2" | sudo tee -a /etc/fstab
UUID=cc4940b4-6e8e-46fe-b43f-d631b237c320 /var/lib/containers xfs defaults 1 2
$ sudo mount /var/lib/containers
$ df -hT | grep containers
/dev/mapper/VGcontainers-LVcontainers xfs 32G 261M 32G 1% /var/lib/containers
Instalando o podman
$ sudo dnf module install container-tools:ol8
$ sudo dnf install podman-plugins
$ for task in enable start is-active; do sudo systemctl ${task} dnsmasq; done
$ podman --help
Manage pods, containers and images
Usage:
podman [options] [command]
Available Commands:
attach Attach to a running container
auto-update Auto update containers according to their auto-update policy
build Build an image using instructions from Containerfiles
commit Create new image based on the changed container
container Manage containers
cp Copy files/folders between a container and the local filesystem
create Create but do not start a container
diff Display the changes to the object's file system
events Show podman events
exec Run a process in a running container
export Export container's filesystem contents as a tar archive
generate Generate structured data based on containers, pods or volumes
healthcheck Manage health checks on containers
help Help about any command
history Show history of a specified image
image Manage images
images List images in local storage
import Import a tarball to create a filesystem image
info Display podman system information
init Initialize one or more containers
inspect Display the configuration of object denoted by ID
kill Kill one or more running containers with a specific signal
load Load image(s) from a tar archive
login Login to a container registry
logout Logout of a container registry
logs Fetch the logs of one or more containers
machine Manage a virtual machine
manifest Manipulate manifest lists and image indexes
mount Mount a working container's root filesystem
network Manage networks
pause Pause all the processes in one or more containers
play Play containers, pods or volumes from a structured file
pod Manage pods
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image from a registry
push Push an image to a specified destination
rename Rename an existing container
restart Restart one or more containers
rm Remove one or more containers
rmi Removes one or more images from local storage
run Run a command in a new container
save Save image(s) to an archive
search Search registry for image
secret Manage secrets
start Start one or more containers
stats Display a live stream of container resource usage statistics
stop Stop one or more containers
system Manage podman
tag Add an additional name to a local image
top Display the running processes of a container
unmount Unmounts working container's root filesystem
unpause Unpause the processes in one or more containers
unshare Run a command in a modified user namespace
untag Remove a name from a local image
version Display the Podman version information
volume Manage volumes
wait Block on one or more containers
Options:
--cgroup-manager string Cgroup manager to use ("cgroupfs"|"systemd") (default "cgroupfs")
--conmon string Path of the conmon binary
-c, --connection string Connection to use for remote Podman service
--events-backend string Events backend to use ("file"|"journald"|"none") (default "file")
--help Help for podman
--hooks-dir strings Set the OCI hooks directory path (may be set multiple times) (default [/usr/share/containers/oci/hooks.d])
--identity string path to SSH identity file, (CONTAINER_SSHKEY)
--log-level string Log messages above specified level (trace, debug, info, warn, warning, error, fatal, panic) (default "warn")
--namespace string Set the libpod namespace, used to create separate views of the containers and pods on the system
--network-cmd-path string Path to the command for configuring the network
--network-config-dir string Path of the configuration directory for networks
--noout do not output to stdout
-r, --remote Access remote Podman service
--root string Path to the root directory in which data, including images, is stored
--runroot string Path to the 'run directory' where all state information is stored
--runtime string Path to the OCI-compatible binary used to run containers. (default "runc")
--runtime-flag stringArray add global flags for the container runtime
--storage-driver string Select which storage driver is used to manage storage of images and containers
--storage-opt stringArray Used to pass an option to the storage driver
--syslog Output logging information to syslog as well as the console (default false)
--tmpdir string Path to the tmp directory for libpod state content.
Note: use the environment variable 'TMPDIR' to change the temporary storage location for container images, '/var/tmp'.
--url string URL to access Podman service (CONTAINER_HOST) (default "unix:/run/user/1000/podman/podman.sock")
-v, --version version for podman
Podman compose
$ sudo curl -o /usr/local/bin/podman-compose https://raw.githubusercontent.com/containers/podman-compose/devel/podman_compose.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 94535 100 94535 0 0 274k 0 --:--:-- --:--:-- --:--:-- 274k
$ sudo chmod +x /usr/local/bin/podman-compose
$ sudo dnf install python3 python3-pyyaml
$ sudo pip3 install python-dotenv
$ podman-compose --help
podman-compose version: 1.0.4
usage: podman-compose [-h] [-v] [--no-pod] [--pod-args pod_args]
[--env-file env_file] [-f file] [-p PROJECT_NAME]
[--podman-path PODMAN_PATH] [--podman-args args]
[--podman-pull-args args] [--podman-push-args args]
[--podman-build-args args] [--podman-inspect-args args]
[--podman-run-args args] [--podman-start-args args]
[--podman-stop-args args] [--podman-rm-args args]
[--podman-volume-args args] [--no-ansi] [--no-cleanup]
[--dry-run]
{help,version,wait,systemd,pull,push,build,up,down,ps,run,exec,start,stop,restart,logs,config,port}
...
optional arguments:
-h, --help show this help message and exit
-v, --version show version
--no-pod disable pod creation
--pod-args pod_args custom arguments to be passed to `podman pod`
--env-file env_file Specify an alternate environment file
-f file, --file file Specify an alternate compose file (default: docker-compose.yml)
-p PROJECT_NAME, --project-name PROJECT_NAME
Specify an alternate project name (default: directory name)
--podman-path PODMAN_PATH
Specify an alternate path to podman (default: use location in $PATH variable)
--podman-args args custom global arguments to be passed to `podman`
--podman-pull-args args
custom arguments to be passed to `podman pull`
--podman-push-args args
custom arguments to be passed to `podman push`
--podman-build-args args
custom arguments to be passed to `podman build`
--podman-inspect-args args
custom arguments to be passed to `podman inspect`
--podman-run-args args
custom arguments to be passed to `podman run`
--podman-start-args args
custom arguments to be passed to `podman start`
--podman-stop-args args
custom arguments to be passed to `podman stop`
--podman-rm-args args
custom arguments to be passed to `podman rm`
--podman-volume-args args
custom arguments to be passed to `podman volume`
--no-ansi Do not print ANSI control characters
--no-cleanup Do not stop and remove existing pod & containers
--dry-run No action; perform a simulation of commands
command:
{help,version,wait,systemd,pull,push,build,up,down,ps,run,exec,start,stop,restart,logs,config,port}
help show help
version show version
wait wait running containers to stop
systemd create systemd unit file and register its compose stacks
When first installed type `sudo podman-compose systemd -a create-unit`
later you can add a compose stack by running `podman-compose systemd -a register`
then you can start/stop your stack with `systemctl --user start podman-compose@<PROJ>`
pull pull stack images
push push stack images
build build stack images
up Create and start the entire stack or some of its services
down tear down entire stack
ps show status of containers
run create a container similar to a service to run a one-off command
exec execute a command in a running container
start start specific services
stop stop specific services
restart restart specific services
logs show logs from services
config displays the compose file
port Prints the public port for a port binding.
Referências