aws-samples / aws-cdk-examples

Example projects using the AWS CDK
Apache License 2.0
4.97k stars 2.11k forks source link

aws-cdk-examples repo PR build is failing with an error - Cannot connect to the Docker daemon #769

Open VikramPatil-AMZ opened 1 year ago

VikramPatil-AMZ commented 1 year ago

Describe the bug

aws-cdk-examples repo PR build is failing while bundle Lambda function code using DOTNET_CORE_3_1.BundlingImage. build error message - docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

As per online article, need to set privileged environment variable to true in the synth definition - https://docs.aws.amazon.com/cdk/api/v2/dotnet/api/Amazon.CDK.Pipelines.html#cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock (search for error message - "Cannot connect to the Docker daemon")

Expected Behavior

Lambda bundle command should bundle the code and PR build should pass.

Current Behavior

PR build is failing. Failed build job - https://github.com/aws-samples/aws-cdk-examples/actions/runs/3364394111/jobs/5578699844

Reproduction Steps

Re-run the PR build.

Possible Solution

As per online article, need to set privileged environment variable to true in the synth definition - https://docs.aws.amazon.com/cdk/api/v2/dotnet/api/Amazon.CDK.Pipelines.html#cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock (search for error message - "Cannot connect to the Docker daemon")

Additional Information/Context

No response

CDK CLI Version

2.X

Framework Version

.Net Core 3.1

Node.js Version

Not aware

OS

Not aware

Language

.NET

Language Version

No response

liyanone commented 1 year ago

The solution mentioned in https://docs.aws.amazon.com/cdk/api/v2/dotnet/api/Amazon.CDK.Pipelines.html#cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock is considered correct. However, this setting should be put in the SynthAction of the new CdkPipeline block in user's own code, instead of making changes in this aws-cdk-examples repo as it does not have any example code for creating AWS CodePipeline at the moment.