You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, querying certain fields of Container will return an error, but they shouldn't. Specifically any of these fields:
stdout
stderr
exitCode
Any other field that requires executing a command in the container
The error occurs when no command has been explicitly defined for this container: in other words, there is no withExec step in the current pipeline.
The typical workaround is to add an explicit withExec(nil), which is very confusing.
However, if the container has either an entrypoint or defaultArgs defined - that should be used as a default command. The fact that it is not, is counter-intuitive and confusing.
Solution
If an exec is required, and withExec has not been called explicitly, call it implicitly with entrypoint + defaultArgs as the arguments.
There are three ways for these fields to be set:
via Directory { dockerBuild } or Container { build }
via Container { pull }
via withEntrypoint and/or withDefaultArgs
Whichever way those fields have been set, they should be honored by the default exec.
See also
This proposal fixes one aspect of the "confusing laziness problem" (#4668).
No one has suggested this so I may be preaching to the choir, but I'm very hesitant to have Dagger automatically figure out what you're trying to do and do it for you. That can make the mental model even harder to grok. My preference would be for us to detect these states and provide a helpful error message so the user understands the mental model in the end.
But I could probably be talked into it. For example maybe I see "Image is subset of Container" because I'm too close to the problem and know the nitty-gritty details. Doing the opposite and consciously blurring that line could be beneficial, assuming there are no downsides. (Don't have time to think of examples at the moment.)
[...] if the container has either an entrypoint or defaultArgs defined - that should be used as a default command. The fact that it is not, is counter-intuitive and confusing.
Yes I agree that we should do this, as I mentioned before. I doesn't make sense to not do it.
[...] That can make the mental model even harder to grok.
@vito Can you clarify how this particular case goes against the mental model?
@vito Can you clarify how this particular case goes against the mental model?
(Sorry for the wall of text...)
My concern is that the current mental model is already hard to grok. 😕 I agree that this change will make this specific case less surprising, but I don't think it moves the needle for API clarity, and I think addressing the root of that problem could reap greater rewards (e.g. clarifying "laziness") while also making Dagger consistent with the rest of the world.
I've noticed that junior and even senior developers can have a really hard time understanding the difference between a container (a running process) and an image (an inert artifact, part of a recipe for a container). This makes "containers" feel more mystical than they really are. It also makes conversations difficult because terms like "streaming" or "publish" mean one thing when discussing containers (tailing logs? exposing ports?) and another thing when discussing images (registry push/pull?), so you can have entire discussions where both parties are talking past each other. Reducing both down to one word in our API vocabulary really forces the issue.
These two concepts have pretty precise definitions, reflected by the OCI image spec and runtime spec and even Docker, so to me it's a shame to muddy the waters and perpetuate the confusion. That's why I mentioned potentially splitting Image out of Container here: #4668 (comment) - which would eliminate this footgun (with type safety) and also give people a better understanding of how containers actually work.
From an API design perspective it's clear to me that we're overloading one type to represent two concepts. Some fields only make sense for images (publish, export, imageRef), while some only make sense for containers (exitCode, stdout, stderr, endpoint, hostname). It's true that there's a pretty strong magnetic attraction between the two but I don't know if welding them together is really helping or if it's just a leaky abstraction.
With this change we almost make the latter set of fields make sense for both, but still only if the image has a default command, and it's not even clear that that's the behavior users expect all the time: #4668 (comment) for example was relying on the fact that we don't run the entrypoint.
It also calls into question whether certain image-specific fields act on the implicit exec or the image. For example, if I do container.From("redis").Publish("redis2") - does that mirror the redis image directly to redis2, or does it implicitly run the default command and hang forever instead? If we add a digest field for getting the vertex digest of a container, does that give me the image digest or the digest of running its default command? Maybe we can define reasonable semantics for each of these scenarios, but my point is the API does nothing to make this clear. You just have to know.
This isn't a hill I'll die on, and maybe it's fine to do this, but with infinite time available I would want to explore the alternative and see how it would look in real world code. I'm more than willing to be wrong / talked out of this since it's much less work. 😄
@vito your concerns seem to be more related to forcing a lazy pipeline to do work. I think that particular problem should be addressed and solved separately in:
The current use of Export, Publish, ExitCode, Stdout to run a pipeline when you don't actually want those things, are very clearly workarounds for that pipeline "synchronization".
If we give a way to explicitly execute a pipeline without resorting to these workarounds, doesn't it make more sense that using stdout and exitCode mean you do want to execute the container and use it's entrypoint and default arguments?
To be clear, I'm suggesting to use those defaults when executing the container, not on Publish for example.
More details below, but TLDR: separating concepts of "image" and "container" are a source of confusion today, and merging them will increase clarity, not decrease it.
I've noticed that junior and even senior developers can have a really hard time understanding the difference between a container (a running process) and an image (an inert artifact, part of a recipe for a container).
Is a container really a running process? That's not Docker's definition - containers can be created without running a process in them; and they continue to exist after the process has exited. This ambiguity has existed since the day we launched Docker. The term "container" means slightly different things to different people, and will continue to do so regardless of what Dagger does.
Likewise, the ubiquitous Dockerfile model blurs the lines between image and container. CMD, WORKDIR, USER etc will affect both the next execs, and the state of the image to be published.
This makes "containers" feel more mystical than they really are.
A container is something you can push, pull, build and run. Nothing mystical about it.
It also makes conversations difficult because terms like "streaming" or "publish" mean one thing when discussing containers (tailing logs? exposing ports?) and another thing when discussing images (registry push/pull?), so you can have entire discussions where both parties are talking past each other. Reducing both down to one word in our API vocabulary really forces the issue.
I don't know about "streaming" (do we use that word anywhere today?)
Publishing a container seems clear to me.
These two concepts have pretty precise definitions, reflected by the OCI image spec and runtime spec and even Docker, so to me it's a shame to muddy the waters and perpetuate the confusion. That's why I mentioned potentially splitting Image out of Container here: #4668 (comment) - which would eliminate this footgun (with type safety) and also give people a better understanding of how containers actually work.
OCI is a snapshot of the Docker team's design process, frozen in time in 2014. There is a not a single original design thought that went into this spec since it was defined.
At that time we were already grappling with the fact that a distinction between image and container feels incomplete and confusing, but we no longer had the luxury of iterating.
From an API design perspective it's clear to me that we're overloading one type to represent two concepts. Some fields only make sense for images (publish, export, imageRef), while some only make sense for containers (exitCode, stdout, stderr, endpoint, hostname). It's true that there's a pretty strong magnetic attraction between the two but I don't know if welding them together is really helping or if it's just a leaky abstraction.
That awkwardness does exist, but it comes from merging "container" and "command" together to better fit GraphQL's chaining style. It is orthogonal to a separation between image and container.
With this change we almost make the latter set of fields make sense for both, but still only if the image has a default command, and it's not even clear that that's the behavior users expect all the time: #4668 (comment) for example was relying on the fact that we don't run the entrypoint.
This is a laziness issue, easily resolved by adding a "lazy" flag in Build and every other operation. What morlay needs, is Build(lazy: false) to get an error right away if the build fails. That is unrelated to image / container.
It also calls into question whether certain image-specific fields act on the implicit exec or the image. For example, if I do container.From("redis").Publish("redis2") - does that mirror the redis image directly to redis2, or does it implicitly run the default command and hang forever instead?
The latter. Why would it run the default command?
If we add a digest field for getting the vertex digest of a container, does that give me the image digest or the digest of running its default command?
The OCI image digest.
Maybe we can define reasonable semantics for each of these scenarios, but my point is the API does nothing to make this clear. You just have to know.
I'm not saying these problems don't exist, but you're comparing them to an ideal where splitting image and container is somehow devoid of its own confusion and problems. From experience I'm telling you: it's a fundamentally flawed model that would result in a much more verbose API for not good reason. Users don't care about images.
(I'm running late for a call and wanted to finish this before, so my words may come across as sharper than they are intended)
Happy to discuss at lenght, I agree it's important to get right.
PS. I agree that addressing the root cause of laziness is more important, and I don't understand why we haven't introduced what seems to me like very simple and lightweight changes like the lazy flag.
Another idea could be that the whole chaining API is lazy.
When you want to actually run/execute it, you pass it to a SDK function.
ctr:=client.Container().From("alpine").WithExec([]string{"echo", "hello"})
execution, err:=dagger.Execute(ctx, ctr)
// use the result of the executionexecution.Stdout()
execution.Stderr()
execution.ExitCode()
It breaks the chain, but it's very explicit.
If we would like to stream the output, there could be another call
Another idea could be that the whole chaining API is lazy. When you want to actually run/execute it, you pass it to a SDK function.
ctr:=client.Container().From("alpine").WithExec([]string{"echo", "hello"})
execution, err:=dagger.Execute(ctx, ctr)
// use the result of the executionexecution.Stdout()
execution.Stderr()
execution.ExitCode()
It breaks the chain, but it's very explicit.
If we would like to stream the output, there could be another call
(I'm running late for a call and wanted to finish this before, so my words may come across as sharper than they are intended)
@shykes I hear you from a product perspective, and I want to believe that we can really simplify the model down to "just containers," but I'm having a hard time fully buying it. My concern is whether we're speaking it into existence without a clear idea of whether it actually helps. But you're probably more in tune with our users in this regard than me.
In my experience, masquerading multiple overlapping-but-not-equivalent concepts as one concept does the opposite of bring clarity. It may simplify marketing, but it just relocates the complexity and exceptions into every developer's head. For a developer-centric tool this feels counter-productive. I experienced some of this with Concourse where we stuck to "everything is a Resource" for way too long.
Is a container really a running process? That's not Docker's definition - containers can be created without running a process in them; and they continue to exist after the process has exited. This ambiguity has existed since the day we launched Docker. The term "container" means slightly different things to different people, and will continue to do so regardless of what Dagger does.
The goal of docker create is still ultimately to create a running process later with docker start. It's useless on its own. Sure, there is more to a container than just the CLONE_NEW* flags passed to clone(), but the process is the most fundamental property, and everything else is in service to it.
A container is something you can push, pull, build and run. Nothing mystical about it.
Easy for you to say! :)
This is only true depending on the state of the container. I can't push and pull a running container. If you tell a junior developer that they can push/pull a container they might imagine something mystical like snapshotting the process's in-memory state and migrating it between machines.
If you were to give me a choice between 1) a single object whose state I need to be aware of in every conversation, and 2) two objects with narrower scope representing each highest-order-bit state, I'm almost always going to prefer 2).
OCI is a snapshot of the Docker team's design process, frozen in time in 2014. There is a not a single original design thought that went into this spec since it was defined.
All of this stands on top of Linux's shoulders, which are the semantics and definition of "container" that I think is useful to understand, and which OCI reasonably accurately represents regardless of where it came from (at least in my eyes).
That awkwardness does exist, but it comes from merging "container" and "command" together to better fit GraphQL's chaining style. It is orthogonal to a separation between image and container.
I don't understand this point or how it's orthogonal. Container is effectively a union of two concepts that overlap in some regards and don't overlap in others. You can easily and transparently chain GraphQL queries while transitioning between types at every step, which is another approach we could have taken.
I'm not saying these problems don't exist, but you're comparing them to an ideal where splitting image and container is somehow devoid of its own confusion and problems. From experience I'm telling you: it's a fundamentally flawed model that would result in a much more verbose API for not good reason.
If I thought it would be more verbose I wouldn't be proposing it. 😄
What I had in mind is something like @dolanor's proposal above, but with the type transparently transitioning from an Image (a lazy value) to a Container (an eager value):
ctr, err:=client.Image(). // a little sacrilegious but hear me outFrom("ubuntu").
WithExec([]string{"apt-get", "update"}). // <- lazy, returns ImageWithExec([]string{"apt-get", "install", "abc"}). // <- lazy, returns ImageRun(ctx) // <- eager! blocks and then returns when Container exits
I think this has a chance of working and avoiding verbosity because in the vast majority of cases, people aren't going to be switching back and forth between Image and Container. They're going to be chaining together a big sequence of commands and saying "go."
It also seems easy to remember because you can think of Images as lazy in the similar manner as you think of Docker images as and Dockerfiles as an inert artifact, as opposed to Containers which are actually running and doing things.
This is not a perfectly thought out schema or anything (it's easy to make something up quickly) but it at least doesn't seem verbose.
Users don't care about images.
I want this part to be true - registries are a pain in the ass, and it's much nicer to just work with code. But you still need to bootstrap somehow, and people still publish their products to registries, so yes, they do seem to care about images to some extent.
PS. I agree that addressing the root cause of laziness is more important, and I don't understand why we haven't introduced what seems to me like very simple and lightweight changes like the lazy flag.
I saw this proposal and drafted a reply but got sidetracked. In short I wasn't a huge fan because passing the flag in the Go SDK seemed pretty verbose and would change the method signature. Or were you seeing lazy: true/false as being represented differently at the SDK level?
(I'm running late for a call and wanted to finish this before, so my words may come across as sharper than they are intended)
@shykes I hear you from a product perspective, and I want to believe that we can really simplify the model down to "just containers," but I'm having a hard time fully buying it. My concern is whether we're speaking it into existence without a clear idea of whether it actually helps. But you're probably more in tune with our users in
this regard than me.
I think it's the other way around: talking about "containers" and "images" as if they were clearly defined concepts that are anchored in technical reality, and well understood by users, may be speaking something into existence without actually helping.
Starting from the technical reality of buildkit, and finding the simplest way to explain that, is a more reliable approach. Here's the technical reality in buildkit:
There is a thing called an "llb state"
The llb state can be exported to an OCI artifact
The llb state can be loaded from an OCI artifact
The llb can be produced by a Docker build
The llb state contains filesystem data
The llb state can be modified by executing commands inside it
The llb state is defined by a "chain" of operations
The llb state contains persistent metadata which affects the next commands (env, user, etc). This metadata can also be mutated
The llb state is content addressed: there is always an exact digest to represent its state
The rough equivalent to "llb state" in a Dockerfile is a "stage" or "target"
So, in terms of the fundamentals of what our engine does, there is only one object - not two. And it is neither called "container" nor "image".
Now, "llb state" is a terrible user-facing name for that unique object, so what should we call it? Of course "image" or "container" come to mind, because they are familiar and closely related. But which one is best?
llb state
image (Docker definition)
container (docker definition)
container (linux definition)
container (layman definition)
Can be exported to an OCI artifact
✅
✅
✅
❌
🤷 what's OCI?
Can be loaded from an OCI artifact
✅
✅
✅
❌
🤷 what's OCI?
Can be produced by a Docker build
✅
✅
❌
❌
✅
Contains filesystem data
✅
✅
✅
❌
✅
Can be modified by executing commands
✅
❌
✅
❌
✅
Contains metadata that affects commands
✅
✅
✅
❌
✅
Defined by a "chain" of operations
✅
❌
❌
❌
🤷
Content addressed
✅
✅
❌
❌
🤷
Rough equivalent to a Dockerfile "stage" or "target"
✅
🤷
🤷
❌
🤷
The point of this table is to show that there's no slam dunk here. We're exposing the llb state to end users, and the closest existing term for that is the Dockerfile "stage" or "target" - but those are too vague.
So we're faced with a design decision that is fuzzy and subjective no matter what we do. The only part that is not fuzzy is that there is only one object under the hood, not two.
My fuzzy and subjective opinion is that calling this object "container" is better. You can argue that "image" is better, but that argument will be just as fuzzy and subjective.
If you were to give me a choice between 1) a single object whose state I need to be aware of in every conversation, and 2) two objects with narrower scope representing each highest-order-bit state, I'm almost always going to prefer 2).
But that's not the situation. The two objects in question don't have a usefully narrower scope, because their definitions are fuzzy and subjective.
OCI is a snapshot of the Docker team's design process, frozen in time in 2014. There is a not a single original design thought that went into this spec since it was defined.
All of this stands on top of Linux's shoulders, which are the semantics and definition of "container" that I think is useful to understand, and which OCI reasonably accurately represents regardless of where it came from (at least in my eyes).
Linux never formally defined the word "container". To the extent that the Linux community defined it, it was fuzzy and fragmented, and didn't have a coherent definition of the role of filesystem state, or serializable metadata. They could never agree on whether a "linux container" was the ephemeral isolated processes, or the stateful context within which they were executed. The Docker definition introduced an additional lens, of the container as artifact. They're called "shipping containers" and not "shipping images" for a reason...
What I had in mind is something like @dolanor's proposal above, but with the type transparently transitioning from an Image (a lazy value) to a Container (an eager value):
ctr, err:=client.Image(). // a little sacrilegious but hear me outFrom("ubuntu").
WithExec([]string{"apt-get", "update"}). // <- lazy, returns ImageWithExec([]string{"apt-get", "install", "abc"}). // <- lazy, returns ImageRun(ctx) // <- eager! blocks and then returns when Container exits
I think I would have way less knee-jerk reactions to this if you kept "Container" at its current definition. Not saying it would resolve our semantic argument on what is / isn't a container but it would decouple the laziness part from it:
ctr, err:=client.Container().
From("ubuntu").
WithExec([]string{"apt-get", "update"}). // <- lazy, returns ContainerWithExec([]string{"apt-get", "install", "abc"}). // <- lazy, returns ContainerRun(ctx) // <- eager! blocks and then returns when all commands are executed in the container
I want this part to be true - registries are a pain in the ass, and it's much nicer to just work with code. But you still need to bootstrap somehow, and people still publish their products to registries, so yes, they do seem to care about images to some extent.
Sure, images are a snapshotting standard for serializing the state of your container, when you need to save it to a file or upload it to a registry. So OCI images still exist, just as an implementation detail of archival / transfer.
Basically it's a small API change but it has large SDK implications.
Seems like it... I don't have a good handle on that part. Makes me wish we had separated the "build pipeline" and "execute pipeline" parts, but that shipped has probably sailed.
The point of this table is to show that there's no slam dunk here. We're exposing the llb state to end users, and the closest existing term for that is the Dockerfile "stage" or "target" - but those are too vague.
So we're faced with a design decision that is fuzzy and subjective no matter what we do. The only part that is not fuzzy is that there is only one object under the hood, not two.
My fuzzy and subjective opinion is that calling this object "container" is better. [...]
@vito's idea to split container and image made sense to me, coming from docker, but @shykes's arguments have me convinced regarding exploring that path. Thanks for laying that out so clearly.
Making sure to deprecate exitCode as a way to just trigger sending the request (doubly worse because it has a bug that'll break users when fixed), it still makes total sense to do what's described in this issue, for fields that actually require an execution:
stdout
stderr
exitCode
Any other field that requires executing a command in the container
@vito's idea to split container and image made sense to me, coming from docker, but @shykes's arguments have me convinced regarding exploring that path. Thanks for laying that out so clearly.
Same here. 👍 And thanks for directing traffic and maintaining focus across these issues. 🙏
I think it's the other way around: talking about "containers" and "images" as if they were clearly defined concepts that are anchored in technical reality, and well understood by users, may be speaking something into existence without actually helping.
These terms may not be anchored in technical reality, but they are anchored in a decade of familiarity that has crystallized in various forms across the entire industry, which has become our technical reality to some extent.
I'm comfortable with going against the grain in an effort to retcon a better mental model, and I don't actually care about keeping the word "image," I just don't want to leave a vacuum in our vocabulary that gives rise to ambiguity. I trust that listening to user feedback and having discussions like this will help prevent that, so thanks for engaging once again. 🙏
My fuzzy and subjective opinion is that calling this object "container" is better. You can argue that "image" is better, but that argument will be just as fuzzy and subjective.
Between the two, "container" is absolutely better and nearly impossible to justify replacing at this point.
For my own mental model, I'm trying to visualize something to replace the deeply entrenched notion of "images" and "containers" transitioning between one another in lockstep. I wonder if this exercise would help others coming from Docker, but maybe it's not needed.
They're called "shipping containers" and not "shipping images" for a reason...
You joke but this may have been the clincher of your argument, since it made me realize that the term "container" usually refers to an inert object, much like how I tried to describe "image." 😂
Or you weren't joking, in which case I would say the phrase "shipping a container" is ambiguous between pushing containers to a registry and deploying containers to a runtime, which actually illustrates my point! 😈
We have drifted from the original discussion with the lazy/non lazy talk, but I agree with the original proposal :)
On the container/image debate, I'm also ok with sticking with just container. When discovering Docker, it confused me a little bit to have 2 different concept that seemed mostly the same. But I guess I integrated that enough that it's hard to forget. But I remember that using docker commit to create an image that I can run again as a container after seemed weird.
On the lazy flag, though, I wonder what would be the effect of chaining a mixed bag of lazy/non-lazy operations:
ctr, err:=client.Container().
From("ubuntu").
WithExec([]string{"apt-get", "update"}, dagger.ContaineWithExecOpts{Lazy: false}). // <- not lazy, execute? Where do we pass the ctx?WithExec([]string{"apt-get", "install", "abc"}). // <- lazy, returns a ContainerRun(ctx) // <- eager! blocks and execute the `apt-get install` then returns when Container exits
Activity
shykes commentedon Mar 23, 2023
FYI @d3rp3tt3
shykes commentedon Mar 23, 2023
@vito has concerns:
helderco commentedon Mar 28, 2023
Yes I agree that we should do this, as I mentioned before. I doesn't make sense to not do it.
@vito Can you clarify how this particular case goes against the mental model?
vito commentedon Mar 28, 2023
(Sorry for the wall of text...)
My concern is that the current mental model is already hard to grok. 😕 I agree that this change will make this specific case less surprising, but I don't think it moves the needle for API clarity, and I think addressing the root of that problem could reap greater rewards (e.g. clarifying "laziness") while also making Dagger consistent with the rest of the world.
I've noticed that junior and even senior developers can have a really hard time understanding the difference between a container (a running process) and an image (an inert artifact, part of a recipe for a container). This makes "containers" feel more mystical than they really are. It also makes conversations difficult because terms like "streaming" or "publish" mean one thing when discussing containers (tailing logs? exposing ports?) and another thing when discussing images (registry push/pull?), so you can have entire discussions where both parties are talking past each other. Reducing both down to one word in our API vocabulary really forces the issue.
These two concepts have pretty precise definitions, reflected by the OCI image spec and runtime spec and even Docker, so to me it's a shame to muddy the waters and perpetuate the confusion. That's why I mentioned potentially splitting
Imageout ofContainerhere: #4668 (comment) - which would eliminate this footgun (with type safety) and also give people a better understanding of how containers actually work.From an API design perspective it's clear to me that we're overloading one type to represent two concepts. Some fields only make sense for images (
publish,export,imageRef), while some only make sense for containers (exitCode,stdout,stderr,endpoint,hostname). It's true that there's a pretty strong magnetic attraction between the two but I don't know if welding them together is really helping or if it's just a leaky abstraction.With this change we almost make the latter set of fields make sense for both, but still only if the image has a default command, and it's not even clear that that's the behavior users expect all the time: #4668 (comment) for example was relying on the fact that we don't run the entrypoint.
It also calls into question whether certain image-specific fields act on the implicit exec or the image. For example, if I do
container.From("redis").Publish("redis2")- does that mirror theredisimage directly toredis2, or does it implicitly run the default command and hang forever instead? If we add adigestfield for getting the vertex digest of a container, does that give me the image digest or the digest of running its default command? Maybe we can define reasonable semantics for each of these scenarios, but my point is the API does nothing to make this clear. You just have to know.This isn't a hill I'll die on, and maybe it's fine to do this, but with infinite time available I would want to explore the alternative and see how it would look in real world code. I'm more than willing to be wrong / talked out of this since it's much less work. 😄
helderco commentedon Mar 28, 2023
@vito your concerns seem to be more related to forcing a lazy pipeline to do work. I think that particular problem should be addressed and solved separately in:
The current use of
Export,Publish,ExitCode,Stdoutto run a pipeline when you don't actually want those things, are very clearly workarounds for that pipeline "synchronization".If we give a way to explicitly execute a pipeline without resorting to these workarounds, doesn't it make more sense that using
stdoutandexitCodemean you do want to execute the container and use it's entrypoint and default arguments?To be clear, I'm suggesting to use those defaults when executing the container, not on
Publishfor example.shykes commentedon Mar 28, 2023
More details below, but TLDR: separating concepts of "image" and "container" are a source of confusion today, and merging them will increase clarity, not decrease it.
Is a container really a running process? That's not Docker's definition - containers can be created without running a process in them; and they continue to exist after the process has exited. This ambiguity has existed since the day we launched Docker. The term "container" means slightly different things to different people, and will continue to do so regardless of what Dagger does.
Likewise, the ubiquitous Dockerfile model blurs the lines between image and container.
CMD,WORKDIR,USERetc will affect both the next execs, and the state of the image to be published.A container is something you can push, pull, build and run. Nothing mystical about it.
OCI is a snapshot of the Docker team's design process, frozen in time in 2014. There is a not a single original design thought that went into this spec since it was defined.
At that time we were already grappling with the fact that a distinction between image and container feels incomplete and confusing, but we no longer had the luxury of iterating.
That awkwardness does exist, but it comes from merging "container" and "command" together to better fit GraphQL's chaining style. It is orthogonal to a separation between image and container.
This is a laziness issue, easily resolved by adding a "lazy" flag in
Buildand every other operation. What morlay needs, isBuild(lazy: false)to get an error right away if the build fails. That is unrelated to image / container.The latter. Why would it run the default command?
The OCI image digest.
I'm not saying these problems don't exist, but you're comparing them to an ideal where splitting image and container is somehow devoid of its own confusion and problems. From experience I'm telling you: it's a fundamentally flawed model that would result in a much more verbose API for not good reason. Users don't care about images.
(I'm running late for a call and wanted to finish this before, so my words may come across as sharper than they are intended)
Happy to discuss at lenght, I agree it's important to get right.
PS. I agree that addressing the root cause of laziness is more important, and I don't understand why we haven't introduced what seems to me like very simple and lightweight changes like the
lazyflag.dolanor commentedon Mar 29, 2023
Another idea could be that the whole chaining API is lazy.
When you want to actually run/execute it, you pass it to a SDK function.
It breaks the chain, but it's very explicit.
If we would like to stream the output, there could be another call
shykes commentedon Mar 29, 2023
I like (love?) that option but there are more considerations, which we explored here: #3555 (comment)
vito commentedon Mar 29, 2023
@shykes I hear you from a product perspective, and I want to believe that we can really simplify the model down to "just containers," but I'm having a hard time fully buying it. My concern is whether we're speaking it into existence without a clear idea of whether it actually helps. But you're probably more in tune with our users in this regard than me.
In my experience, masquerading multiple overlapping-but-not-equivalent concepts as one concept does the opposite of bring clarity. It may simplify marketing, but it just relocates the complexity and exceptions into every developer's head. For a developer-centric tool this feels counter-productive. I experienced some of this with Concourse where we stuck to "everything is a Resource" for way too long.
The goal of
docker createis still ultimately to create a running process later withdocker start. It's useless on its own. Sure, there is more to a container than just theCLONE_NEW*flags passed toclone(), but the process is the most fundamental property, and everything else is in service to it.Easy for you to say! :)
This is only true depending on the state of the container. I can't push and pull a running container. If you tell a junior developer that they can push/pull a container they might imagine something mystical like snapshotting the process's in-memory state and migrating it between machines.
If you were to give me a choice between 1) a single object whose state I need to be aware of in every conversation, and 2) two objects with narrower scope representing each highest-order-bit state, I'm almost always going to prefer 2).
All of this stands on top of Linux's shoulders, which are the semantics and definition of "container" that I think is useful to understand, and which OCI reasonably accurately represents regardless of where it came from (at least in my eyes).
I don't understand this point or how it's orthogonal. Container is effectively a union of two concepts that overlap in some regards and don't overlap in others. You can easily and transparently chain GraphQL queries while transitioning between types at every step, which is another approach we could have taken.
If I thought it would be more verbose I wouldn't be proposing it. 😄
What I had in mind is something like @dolanor's proposal above, but with the type transparently transitioning from an
Image(a lazy value) to aContainer(an eager value):(Related: #4723)
I think this has a chance of working and avoiding verbosity because in the vast majority of cases, people aren't going to be switching back and forth between
ImageandContainer. They're going to be chaining together a big sequence of commands and saying "go."It also seems easy to remember because you can think of Images as lazy in the similar manner as you think of Docker images as and Dockerfiles as an inert artifact, as opposed to Containers which are actually running and doing things.
This is not a perfectly thought out schema or anything (it's easy to make something up quickly) but it at least doesn't seem verbose.
I want this part to be true - registries are a pain in the ass, and it's much nicer to just work with code. But you still need to bootstrap somehow, and people still publish their products to registries, so yes, they do seem to care about images to some extent.
I saw this proposal and drafted a reply but got sidetracked. In short I wasn't a huge fan because passing the flag in the Go SDK seemed pretty verbose and would change the method signature. Or were you seeing
lazy: true/falseas being represented differently at the SDK level?In Go, for example, this:
...would turn into this:
...which would need to be a different method since the signature is entirely different. Also we've got a boolean defaulting to
truewhich is tricky.Basically it's a small API change but it has large SDK implications.
shykes commentedon Mar 29, 2023
I think it's the other way around: talking about "containers" and "images" as if they were clearly defined concepts that are anchored in technical reality, and well understood by users, may be speaking something into existence without actually helping.
Starting from the technical reality of buildkit, and finding the simplest way to explain that, is a more reliable approach. Here's the technical reality in buildkit:
So, in terms of the fundamentals of what our engine does, there is only one object - not two. And it is neither called "container" nor "image".
Now, "llb state" is a terrible user-facing name for that unique object, so what should we call it? Of course "image" or "container" come to mind, because they are familiar and closely related. But which one is best?
The point of this table is to show that there's no slam dunk here. We're exposing the llb state to end users, and the closest existing term for that is the Dockerfile "stage" or "target" - but those are too vague.
So we're faced with a design decision that is fuzzy and subjective no matter what we do. The only part that is not fuzzy is that there is only one object under the hood, not two.
My fuzzy and subjective opinion is that calling this object "container" is better. You can argue that "image" is better, but that argument will be just as fuzzy and subjective.
But that's not the situation. The two objects in question don't have a usefully narrower scope, because their definitions are fuzzy and subjective.
Linux never formally defined the word "container". To the extent that the Linux community defined it, it was fuzzy and fragmented, and didn't have a coherent definition of the role of filesystem state, or serializable metadata. They could never agree on whether a "linux container" was the ephemeral isolated processes, or the stateful context within which they were executed. The Docker definition introduced an additional lens, of the container as artifact. They're called "shipping containers" and not "shipping images" for a reason...
I think I would have way less knee-jerk reactions to this if you kept "Container" at its current definition. Not saying it would resolve our semantic argument on what is / isn't a container but it would decouple the laziness part from it:
Sure, images are a snapshotting standard for serializing the state of your container, when you need to save it to a file or upload it to a registry. So OCI images still exist, just as an implementation detail of archival / transfer.
Seems like it... I don't have a good handle on that part. Makes me wish we had separated the "build pipeline" and "execute pipeline" parts, but that shipped has probably sailed.
helderco commentedon Mar 30, 2023
@vito's idea to split container and image made sense to me, coming from docker, but @shykes's arguments have me convinced regarding exploring that path. Thanks for laying that out so clearly.
So, if we focus on resolving the lazyness in:
Making sure to deprecate
exitCodeas a way to just trigger sending the request (doubly worse because it has a bug that'll break users when fixed), it still makes total sense to do what's described in this issue, for fields that actually require an execution:vito commentedon Mar 31, 2023
@helderco
Same here. 👍 And thanks for directing traffic and maintaining focus across these issues. 🙏
@shykes
These terms may not be anchored in technical reality, but they are anchored in a decade of familiarity that has crystallized in various forms across the entire industry, which has become our technical reality to some extent.
I'm comfortable with going against the grain in an effort to retcon a better mental model, and I don't actually care about keeping the word "image," I just don't want to leave a vacuum in our vocabulary that gives rise to ambiguity. I trust that listening to user feedback and having discussions like this will help prevent that, so thanks for engaging once again. 🙏
Between the two, "container" is absolutely better and nearly impossible to justify replacing at this point.
For my own mental model, I'm trying to visualize something to replace the deeply entrenched notion of "images" and "containers" transitioning between one another in lockstep. I wonder if this exercise would help others coming from Docker, but maybe it's not needed.
You joke but this may have been the clincher of your argument, since it made me realize that the term "container" usually refers to an inert object, much like how I tried to describe "image." 😂
Or you weren't joking, in which case I would say the phrase "shipping a container" is ambiguous between pushing containers to a registry and deploying containers to a runtime, which actually illustrates my point! 😈
helderco commentedon Apr 4, 2023
Do I understand correctly that there's consensus on moving forward with this proposal? Do we need more feedback? @aluzzardi @sipsma?
vito commentedon Apr 4, 2023
@helderco Yep. Curious what others think but I think we can move forward either way.
dolanor commentedon Apr 5, 2023
We have drifted from the original discussion with the lazy/non lazy talk, but I agree with the original proposal :)
On the container/image debate, I'm also ok with sticking with just container. When discovering Docker, it confused me a little bit to have 2 different concept that seemed mostly the same. But I guess I integrated that enough that it's hard to forget. But I remember that using
docker committo create an image that I can run again as a container after seemed weird.On the
lazyflag, though, I wonder what would be the effect of chaining a mixed bag of lazy/non-lazy operations: