Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: sam local invoke - Docker - Have you got it installed and running #5059

Closed
mattiamatrix opened this issue Apr 21, 2023 · 5 comments
Closed
Labels
area/docker blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days

Comments

@mattiamatrix
Copy link

Description:

I have seen similar issues around but I am not sure this is exactly the same. When I try to local invoke a Lambda defined in my cdk project I get the error Error: Running AWS SAM projects Locally requires Docker. Have you got it installed and running?. But Docker is clearly running in the background.

I read something about DOCKER_HOST but if I touch the cdk build breaks instead

image

sam --version: SAM CLI, version 1.81.0
docker --version: Docker version 20.10.24, build 297e128

Steps to reproduce:

sam local invoke -t

Observed result:

Error

Expected result:

No error

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: macOs 13.3.1 (22E261)
  2. sam --version: SAM CLI, version 1.81.0
  3. AWS region: n/a
{
  "version": "1.81.0",
  "system": {
    "python": "3.8.16",
    "os": "macOS-13.3.1-arm64-arm-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "Not available",
    "aws_cdk": "2.74.0 (build 70e2a33)",
    "terraform": "Not available"
  }
}```

`Add --debug flag to command you are running`
@mattiamatrix mattiamatrix added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Apr 21, 2023
@mattiamatrix mattiamatrix changed the title sam local invoke - Docker - Have you got it installed and running Bug: sam local invoke - Docker - Have you got it installed and running Apr 21, 2023
@lucashuy
Copy link
Contributor

Hi, thanks for opening this issue! It looks like the Docker context might be using a different context than what SAM CLI expects (from your screenshot, where Context: desktop-linux).

Following #4329 (comment), does this work around work for you?

@lucashuy lucashuy added area/docker blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Apr 21, 2023
@mattiamatrix
Copy link
Author

mattiamatrix commented Apr 21, 2023

My understanding is that updating DOCKER_HOST might affect other applications.

sudo ln -sf "$HOME/.docker/run/docker.sock" /var/run/docker.sock suggested here looks a workaround

@lucashuy
Copy link
Contributor

Setting the DOCKER_HOST environment variable right before the command (DOCKER_HOST=<...> sam local invoke ...) should only set it for that particular command run. Symlinking the Docker socket in the home directory to the default Docker one should work, however this seems to be more of a global approach since this persists and will affect things other than SAM CLI.

@mildaniel
Copy link
Contributor

Seems like discussions on this issue have stalled so I will close this out now. Should anything else arise or you have anymore questions, please don't hesitate to open up a new issue.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docker blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days
Projects
None yet
Development

No branches or pull requests

3 participants