# Using "sam build" to create AWS image for lambda funtion in pipeline

**URL:** <https://community.codefresh.io/t/using-sam-build-to-create-aws-image-for-lambda-funtion-in-pipeline/687>\
**Category:** Pipeline Workflows\
**Created:** [December 3, 2021, 3:18pm UTC](https://community.codefresh.io/t/using-sam-build-to-create-aws-image-for-lambda-funtion-in-pipeline/687 "2021-12-03T15:18:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jakub\_Gladykowski](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/jakub_gladykowski/32/438_2.png) [@Jakub\_Gladykowski](https://community.codefresh.io/u/Jakub_Gladykowski)\
**Post date:** [December 3, 2021, 3:18pm UTC](https://community.codefresh.io/t/using-sam-build-to-create-aws-image-for-lambda-funtion-in-pipeline/687/1 "2021-12-03T15:18:57Z")

</div>

Hey,

I’m trying to build & deploy AWS lambda function by replicating local process in Codefresh pipeline.

In the pipeline I build image with all resources and execute `sam build` I get error - `requires Docker. is Docker running?` which totally makes sense - after all I’m executing commands inside docker image, which does not have docker inside. I tried to expose docker inside docker using

```auto
     volumes:
      - /var/run/docker.sock:/var/run/docker.sock

```

also without luck. So is there a way to `sam build` in Codefresh pipeline, or I need more programatical way of creating image ?

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [December 8, 2021, 10:12am UTC](https://community.codefresh.io/t/using-sam-build-to-create-aws-image-for-lambda-funtion-in-pipeline/687/2 "2021-12-08T10:12:47Z")

</div>

Hello and welcome to the Codefresh community

For security reasons the raw docker socket is not available in pipeline in the SAAS version of Codefresh. It is only available if you are using your own infrastructure with the Codefresh runner.  
The proper way to use docker in a codefresh pipeline is via the [build](https://codefresh.io/docs/docs/codefresh-yaml/steps/build/) and [push](https://codefresh.io/docs/docs/codefresh-yaml/steps/push/) steps.

I am not an expert in Lambda but I think you with need to use the `--container` argument in the `sam build` command to inform sam that you already inside a container. Alternatively you should explore the `sam package` command.
