Skip to content

SAM CLI with Docker Desktop alternatives in Windows environment

0

IHAC trying to steer developers to use Docker Desktop alternatives to avoid Docker’s license push. It works well in most cases, especially on macOS. It works differently in Windows machines due to the different PATH format. They are able to work around most of the issues for straight container build scenarios; however, can’t get it work properly with SAM CLI (local serverless/lambda).

Build folders are empty after a success “sam build --use-container”. Build artifacts were not created/copied into the folder.

AWS
asked a year ago320 views
1 Answer
1

When using AWS SAM CLI with Docker alternatives in a Windows environment, you may encounter issues with the build process. The AWS SAM CLI uses Docker to provide a local environment similar to AWS Lambda for building, testing, and debugging serverless applications.

While AWS SAM officially supports Docker Desktop for Windows, starting from AWS SAM CLI version 1.47.0, alternatives using the Docker runtime are acceptable. However, the issues you're experiencing with empty build folders after running sam build --use-container may be related to how these Docker alternatives handle file paths in Windows.

Here are some potential solutions:

  1. Try using the --no-use-container flag with the sam build command. This option allows you to run the build on your local machine instead of in a Docker container, which might bypass the path-related issues:
sam build --no-use-container
  1. Check if your Docker alternative is properly configured to handle volume mounting between the host and container, which is essential for SAM CLI to copy build artifacts back to your local directory.

  2. Ensure that your Docker alternative has the necessary permissions to access and write to the directories where SAM CLI is trying to place the build artifacts.

  3. If you continue to experience issues with Docker alternatives, you might need to consider using Docker Desktop specifically for SAM CLI operations, while using alternatives for other container workloads.

The empty build folders suggest that while the build process may be completing successfully within the container, the artifacts aren't being properly copied back to your local file system, which is likely due to path mapping issues between Windows and the Docker alternative you're using.
Sources
Installing Docker to use with the AWS SAM CLI - AWS Serverless Application Model
sam build - AWS Serverless Application Model
AWS SAM CLI troubleshooting - AWS Serverless Application Model

answered a year ago
EXPERT
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.