Hi everyone, I'm new to Pulumi and have been acti...
# typescript
m
Hi everyone, I'm new to Pulumi and have been actively using it for about a month to prepare our production setup defined as Infrastructure as Code (IaC). I'm building a Docker image using
@pulumi/docker-build
and running this image via
@pulumi/docker
. I occasionally struggle with the Docker state in the stack and am unsure if this is due to the maturity of the packages or my implementation (I'm not doing anything unusual). Here's an example of what I'm experiencing: 1. My image is built and pushed to the Docker Hub registry. 2. I use build image
ref
as the name for the
docker.RemoteImage
pulled from Docker Hub. 3. The image is deployed to the container, and everything works fine. 4. Subsequent Pulumi runs show no changes, which is great. However, when I change the Docker provider name, things start to fall apart. This change naturally replaces/updates the containers using this provider, but it results in the following error:
Copy code
docker:index:Container (dev-server-02-run-server-container):
  error: 1 error occurred:
      * Unable to create container: Error response from daemon: Conflict. The container name "/server-dev" is already in use by container "8486e48261ca160e4b63640f050d1cb763ef7ab1c705e7afe2171d5c9ca5f992". You have to remove (or rename) that container to be able to reuse that name.
I'm not sure if I'm doing something wrong or if there's a better way to adjust my workflow. I find myself spending a lot of time dealing with stack Docker states, where I have to manually delete resources and reinitialize them. Does anyone have any thoughts or advice on how to handle this more efficiently? Thank you!
l
It looks like Pulumi is trying to create an image and is hitting a name clash. At a guess, you're setting the
name
arg (part of parameter 2 to a constructor), thereby removing the random string that helps ensure name uniqueness. Find the place where you're setting the name and remove it: allow Pulumi to avoid this problem for you.
👀 1