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

quick-fall-21011

01/02/2022, 7:57 AM
Hi all, I'm at the end of the road with trying to get a pulumi project to deploy my stack. The issue stems from having a base image that has both dotnet and also docker installed. My pulumi project has
Copy code
var image = new Image("my-image", new ImageArgs
        {
            ImageName = Output.Format($"{registry.LoginServer}/{CustomImage}:v1.0.0"),
            Build = new DockerBuild
            {
                Context = relativePath
            },
            Registry = registryInfo,
        });
Running this locally on my machine works fine, since I have dotnet (which builds my pulumi csproj) and also have docker (which is required to build this image. Running this in circle-ci, I'm not able to find an image that satisfies both conditions. Ideally I'd like to have my whole stack defined in pulumi, but looks more like I need to build the container outside of pulumi thru some other circle-ci orb. Any suggestions/thoughts would be appreciated
The example given here does not take into account running in a CI/CD environment - https://www.pulumi.com/blog/build-publish-containers-iac/
s

straight-intern-77892

01/02/2022, 8:49 AM
I think you need to create a custom docker image with both dotnet and docker in it and then tell circle to use this image for building: https://circleci.com/docs/2.0/custom-images/
Looks like you can just use the pulumi/pulumi for this.
q

quick-fall-21011

01/02/2022, 12:42 PM
@straight-intern-77892 Thanks for replying - will give it a go
By running
Copy code
docker run -it --rm --name test --entrypoint /bin/bash  pulumi/pulumi
I can see both
dotnet
and
docker
are available
Unfortunately it failed with
Copy code
+  docker:image:Image my-image creating Starting docker build and push...
 +  docker:image:Image my-image creating Logging in to registry...
 +  docker:image:Image my-image creating Executing ' docker version -f {{json .}}'
 +  docker:image:Image my-image creating {"Client":{"Platform":{"Name":"Docker Engine - Community"},"Version":"20.10.12","ApiVersion":"1.41","DefaultAPIVersion":"1.41","GitCommit":"e91ed57","GoVersion":"go1.16.12","Os":"linux","Arch":"amd64","BuildTime":"Mon Dec 13 11:45:48 2021","Context":"default","Experimental":true},"Server":null}
 +  docker:image:Image my-image creating error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
 +  docker:image:Image my-image creating ' docker version -f {{json .}}' failed with exit code 1
 +  docker:image:Image my-image creating error: Pulumi.ResourceException: No 'docker' command available on PATH: Please install to use container 'build' mode.
and a bit more context further down
Copy code
docker:image:Image (my-image):
    error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
    error: Pulumi.ResourceException: No 'docker' command available on PATH: Please install to use container 'build' mode.
       at async Task<bool> Pulumi.Docker.Docker.UseDockerPasswordStdin(Resource logResource)+detectPasswordStdin(?)
       at async Task Pulumi.Docker.Docker.LoginToRegistry(ImageRegistryUnwrap registry, Resource logResource)+(?) => { }
This is using the
pulumi/pulumi
image
Docker is clearly available as
Version":"20.10.12
but no running?
@straight-intern-77892 ☝️
b

billowy-army-68599

01/02/2022, 1:54 PM
@quick-fall-21011 this appears to be related to circle-ci's docker support. You're building a docker image inside docker You need to look up how to run docker in docker in circleci. This is a generic article which explains that a bit more: https://devopscube.com/run-docker-in-docker/
🙌 1
a quick google tells me circle ci has a setup remote docker mechanism which may help, but I'm not familiar with circleci
s

straight-intern-77892

01/02/2022, 3:03 PM
Looks like you do not have access to the docker socket within your build container.. you'll have to figure out how to provide access or try an alternative approach (not building your image in pulumi)
q

quick-fall-21011

01/03/2022, 12:36 AM
Thanks for the advice both... will dig a bit more
Bingo! I had to follow this article https://circleci.com/docs/2.0/building-docker-images/
Specifically
Copy code
- setup_remote_docker:
          version: 19.03.13
s

straight-intern-77892

01/03/2022, 8:57 AM
👏
148 Views