0

Both buildah run, and podman exec run programs in active containers,

buildah-run - Run a command inside of the container.
podman-exec - Execute a command in a running container

However, only buildah run supports a --hostname options? Why aren't these commands in parity? Why do they have different capabilities?

Put another way, buildah currently has a broken --hostname option, but it's not clear to my why it would ever work. With podman the option is set when you launch the container and with buildah that's done with buildah from so shouldn't buildah from have the --hostname argument?

Evan Carroll
  • 28,578
  • 45
  • 164
  • 290

2 Answers2

0

buildah run is closer in relation to podman run which supports --hostname.

podman exec has to exec into a running container, while buildah run and podman run create new containers.

BTW the purpose of buildah run is to run a container to help build a container image. Podman run is more general purpose.

rhatdan
  • 271
  • 1
  • 3
  • `buildah run` doesn't create a running container, right? That's what `buildah from` does. – Evan Carroll Nov 16 '20 at 16:02
  • see my update to this. – Evan Carroll Nov 17 '20 at 00:29
  • `buildah from` creates a buildah container, similar to podman create creating a podman container. `buildah run` executes the created by `buildah from`. Buildah run is the equivalent of the RUN command inside of a Containerfile or Dockerfile – rhatdan Nov 17 '20 at 20:02
  • But how is a "buildah container" different from a "podman container"? They're both OCI containers, right? `buildah run` executes a command in a container. Dockerfile `RUN ` executes a command inside a container (though it doesn't matter because I'm not using Dockerfiles anymore, I'm using shell scripts -- thanks to your advice). And `podman exec` executes a command inside a container. So what's the difference here? – Evan Carroll Nov 18 '20 at 00:52
  • Put another way, `RUN` is a command in a Dockerfile. Obviously buildah and podman parse Dockerfiles. Why would you translate it to `buildah run` rather than `podman exec`? – Evan Carroll Nov 18 '20 at 00:54
  • This is what I was told on reddit as to the distinction, "Buildah works on offline containers whereas podman exec works on online containers". I would like to know more about that distinction. What is the difference between an offline and online container in this context? Is this documented anywhere? Especially when buildah runs commands inside offline containers? – Evan Carroll Nov 18 '20 at 00:56
0

The reason here requires a bit of explanation,

  • A container is any set of namespaces and capabilities conceptually linked.
  • A container is running (state) when any process in the container is currently executing.
  • Most namespaces (except the user one I believe) must be set before the container is running.
  • Changes in a namespace are seen by all processes in that namespace.
  • buildah run starts a container that is not running, and initializes those namespaces. Because it knows nothing else is running inside the namespaces, it does not have to worry about adverse affects of changing them.
  • podman exec takes a running container and starts another process with the same PID (and other) namespaces. Because it doesn't initialize the namespace, any change inside the namespace would affect all other processes attached to those namespaces. For this reason, namespaces modifications are disabled.
Evan Carroll
  • 28,578
  • 45
  • 164
  • 290