podman-generate-spec(1)

podman-generate-spec(1) 🫢

okay so we're in the podman-generate-spec(1) page from the General Commands Manual and honestly? iconic πŸ’–

✨ NAME ✨

podman-generate-spec β€” Generate Specgen JSON based on containers or pods

🌈 SYNOPSIS 🌈

podman generate spec [options] *container | pod

πŸ¦‹ DESCRIPTION πŸ¦‹

podman generate spec generates SpecGen JSON from Podman Containers and Pods. This JSON can be printed to a file, directly to the command line, or both β€” pick your vibe πŸ’….

This JSON can then be used as input for the Podman API, specifically for Podman container and pod creation. Specgen is Podman's internal structure for formulating new container-related entities. It's lowkey the blueprint energy behind new container stuff, periodt πŸŽ€.

πŸ’… OPTIONS πŸ’…

  • --compact, -c β€” Print the output in a compact, one line format. This is useful when piping the data to the Podman API.
  • --filename, -f=filename β€” Output to the given file.
  • --name, -n β€” Rename the pod or container, so that it does not conflict with the existing entity. This is helpful when the JSON is to be used before the source pod or container is deleted.

🌸 EXAMPLES 🌸

Generate Specgen JSON based on a container 🧚

$ podman generate spec container1
{
 "name": "container1-clone",
 "command": [
  "/bin/sh"
 ],
 "env": {
  "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "container": "podman"
 },
 "sdnotifyMode": "container",
 "pidns": {
  "nsmode": "default"
 },
 "utsns": {
  "nsmode": "private"
 },
 "containerCreateCommand": [
  "podman",
  "run",
  "--name",
  "container1",
  "cea2ff433c61"
 ],
 "init_container_type": "",
 "image": "cea2ff433c610f5363017404ce989632e12b953114fefc6f597a58e813c15d61",
 "ipcns": {
  "nsmode": "default"
 },
 "shm_size": 65536000,
 "shm_size_systemd": 0,
 "selinux_opts": [
  "disable"
 ],
 "userns": {
  "nsmode": "default"
 },
 "idmappings": {
  "HostUIDMapping": true,
  "HostGIDMapping": true,
  "UIDMap": null,
  "GIDMap": null,
  "AutoUserNs": false,
  "AutoUserNsOpts": {
   "Size": 0,
   "InitialSize": 0,
   "PasswdFile": "",
   "GroupFile": "",
   "AdditionalUIDMappings": null,
   "AdditionalGIDMappings": null
  }
 },
 "umask": "0022",
 "cgroupns": {
  "nsmode": "default"
 },
 "netns": {
  "nsmode": "pasta"
 },
 "Networks": null,
 "use_image_hosts": false,
 "resource_limits": {}
}

Generate Specgen JSON based on a container β€” single line edition ✨

The output is single line.
$ podman generate spec --compact container1
{"name":"container1-clone","command":["/bin/sh"],...

Generate Specgen JSON based on a container, writing the output to the specified file πŸŽ€

$ podman generate spec --filename output.json container1
output.json
$ cat output.json
{
 "name": "container1-clone",
 "command": [
  "/bin/sh"
 ],
 "env": {
  "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "container": "podman"
 },
 "sdnotifyMode": "container",
 "pidns": {
  "nsmode": "default"
 },
 "utsns": {
  "nsmode": "private"
 },
 "containerCreateCommand": [
  "podman",
  "run",
  "--name",
  "container1",
  "cea2ff433c61"
 ],
 "init_container_type": "",
 "image": "cea2ff433c610f5363017404ce989632e12b953114fefc6f597a58e813c15d61",
 "ipcns": {
  "nsmode": "default"
 },
 "shm_size": 65536000,
 "shm_size_systemd": 0,
 "selinux_opts": [
  "disable"
 ],
 "userns": {
  "nsmode": "default"
 },
 "idmappings": {
  "HostUIDMapping": true,
  "HostGIDMapping": true,
  "UIDMap": null,
  "GIDMap": null,
  "AutoUserNs": false,
  "AutoUserNsOpts": {
   "Size": 0,
   "InitialSize": 0,
   "PasswdFile": "",
   "GroupFile": "",
   "AdditionalUIDMappings": null,
   "AdditionalGIDMappings": null
  }
 },
 "umask": "0022",
 "cgroupns": {
  "nsmode": "default"
 },
 "netns": {
  "nsmode": "pasta"
 },
 "Networks": null,
 "use_image_hosts": false,
 "resource_limits": {}
}

and that's a wrap on podman-generate-spec(1) from the General Commands Manual β€” go generate those specs and slay, bestie πŸ’–βœ¨πŸ«Ά

πŸ“¦ where this page comes from