https://pulumi.com logo
#general
Title
# general
m

melodic-car-16900

06/10/2021, 10:58 AM
Hey, I’m trying to use Pulumi to build and run docker containers locally. When I call pulumi destroy however, the running containers aren’t killed - do I have to kill them myself…?
b

brave-planet-10645

06/10/2021, 1:10 PM
Can you share some code? They should be destroyed I think
m

melodic-car-16900

06/10/2021, 4:08 PM
🙏 thanks, give me 2 minutes
So pretty simple, just build and run a container. Pulumi up works just fine.
Cool
But then when I run Pulumi destroy, that container is still running
Any ideas you might have @brave-planet-10645 would be greatly appreciated
b

brave-planet-10645

06/11/2021, 10:02 AM
What version of pulumi and the docker provider are you running? If I run the following mine gets deleted. I'm running the latest versions of pulumi and docker provider:
Copy code
import * as docker from "@pulumi/docker";

const nginx = new docker.RemoteImage("nginxRemote", {
    name: "nginx"
});

const nginxContainer = new docker.Container("nginxlocal", {
    image: nginx.latest,
    ports: [{
        external: 8080,
        internal: 80
    }]
})
m

melodic-car-16900

06/11/2021, 8:44 PM
Interesting, they should both be latest, but I’ll check. Thanks so much for providing a working example, I’m sure I’ll figure it out given this is true. I’ll let you know what I find, I’d guess it’s something to do with rm or something
@brave-planet-10645 the use of the
rm
option appears to be my issue. By adding it to your example, I get this issue:
Copy code
Diagnostics:
  docker:index:RemoteImage (nginxRemote):
    error: deleting urn:pulumi:local::mast::docker:index/remoteImage:RemoteImage::nginxRemote: Unable to remove Docker image: Error response from daemon: conflict: unable to remove repository reference "nginx" (must force) - container ff381712dcfd is using its referenced image d1a364dc548d

  pulumi:pulumi:Stack (mast-local):
    error: update failed
when running destroy.
Given that it looks like pulumi clears up the file system that would be removed by rm on destroy anyway (?) - I'm pretty sure I can just not use this option. But it was certainly confusing.
Thanks for your help
2 Views