has anyone had trouble with `@pulumi/docker` frequ...
# general
b
has anyone had trouble with
@pulumi/docker
frequently replacing containers even though you didn't change anything. i think the stack state is becoming unsynchronized. maybe it's because i'm using OrbStack?
l
It's becoming accepted that @pulumi/docker is no longer the way to go. Use @pulumi/docker-build
b
@little-cartoon-10569 isn't that only for building images?
l
What are you using @pulumi/docker for?
b
creating containers locally on my macOS machine, where I have orbstack installed
l
What did you mean by "replacing containers"? If there is no code to build the image, then what is being replaced?
b
Pulumi reports the logOpts, memorySwap, and networkMode as having changed, even though I'm 100% sure nothing changed on my end. To me, this is evidence that Pulumi's state drifted from what actually exists in Docker
l
Ah. I see. Is it possible that those are defaulted in your container resource? Or are you explicitly providing them?
If they're defaulted, then most likely you did a refresh at some point in the past and Docker itself has drifted.
b
it's happening on every
pulumi up
run. no refreshes in between. every
docker.Container
replaces itself, citing logOpts/memorySwap/networkMode as the culprit
l
Are you setting those values in your code? It may be that they're being ignored by your docker engine.
b
none of them are set by me ever
l
Then I suggest adding them. The engine / server may be doing something different to what the provider is expecting.
I've had the opposite happen to me; your situation is a bit odd, but things happen, eh?
b
good suggestion. i had the same idea, but it's wee bit annoying, so i was hoping it was a known issue. but such is life as a developer 🙂
l
Yep. More than once in situations a bit like yours, I've had to refresh a particular resource, export the state, and add all the properties in that resource's state to my code. I gave up even caring what the offending property was, I just copied them all.
b
so i did as you suggested, yet the issue remains. though the culprit is different now. [diff: ~image] any idea what that means? in one case, it's being reported for a container using 'redis:7.4.2' as its image property.
l
Is it reporting a different image but not redeploying anything? If so, that sort of thing is caused by the image property being generated in a way that means Pulumi can't tell what the value is during the preview. Maybe an apply() with some logic in it, or something. This can be safely ignored; it may also be possible to change the logic to prevent this, but that's not always possible. If it is correctly detecting a different image, you might check the history for the image. Has the same tag been overwritten by the image publisher? It may be that the provider checks hashes and has detect a valid change in the image, and is correctly trying to redeploy.
b
It appears to be happening with every docker container I'm deploying. All of them have images with fixed versions.
i did
pulumi stack export
and the reported
image
input is identical to what I specify in my code
l
It kinda makes sense that the memorySwap and similar values aren't being kept constant. A container isn't really a deployable or maintainable thing at all: that's what the image is. As I understand it, a container is a running (or stopped...) instance of an image. And it changes all the time: the values in its memory change, the values on its disc change, and its operating parameters, as controlled by the runtime service / engine, change. Perhaps this is just the way it works.
I've never considered managing a container in Pulumi. Perhaps it's not the correct tool for the job?
b
Seems to me that anything you can create, read, update, and destroy is valid as a Pulumi resource. I mean, the
@pulumi/docker
package has a Container resource, so that reinforces the idea that my intent is logical.
I wonder if there isn't a bug in the resource provider causing this, rather than user error or a fundamental misalignment between Docker and Pulumi.
l
It's possible that a bug is causing this,
I mean, the @pulumi/docker package has a Container resource, so that reinforces the idea that my intent is logical.
I think that people sometimes create code that isn't a good idea 🙂 The purpose may have been to wrap the
docker run
API in Pulumi, but that doesn't mean it's a good idea. It is, to my mind, very similar to the idea of using the AWS BucketObject resource to copy files around inside a file management service or app. Technically valid, but not a good idea.
b
Absolutely, and in theory, if Pulumi is the only actor managing a resource, anything with a lifecycle can be managed by Pulumi.
Found a fix. Just needed to use
docker.RemoteImage
instead of a plain
"postgres:17"
string