Open bryancornies opened 2 years ago
Thanks for raising the issue!
sam build
does not build inside a container by default. Can you please try using the --use-container
option to enable building inside container?
sam build --docker-network <network id> --use-container
I tried running sam build --docker-network host --use-container
but the network still shows as bridge
when the container is running. It appears to me that sam's --docker-network
option doesn't get passed to the docker build --network
option:
--network string Set the networking mode for the RUN instructions during build (default "default")
The specific issue I'm running into is one of the RUN
commands in my Dockerfile
performs a yum install
from behind a proxy. The command fails because our corporate proxy is not reachable from the default bridge
Docker network so I have to be able to set the network to host
when building the Docker image.
Can confirm - there is no effect from using --docker-network host
flag
Why was this closed, is there a solution I'm not seeing?
does anybody have a solution for this? i am having this issue too!!!
Description:
When running
sam build --docker-network host
I am expecting the Docker container that is under build to use the network specified by thedocker-network
flag.Steps to reproduce:
RUN SLEEP 100
to the Dockerfile to force the build process to pause so it can be inspectedsam build --docker-network host
docker inspect --format='{{range $k, $v := .NetworkSettings.Networks}}{{$k}}{{end}}' [container]
Observed result:
Regardless of what is passed to the
--docker-network
flag, the under-build Docker container always uses thebridge
network.Expected result:
I would expect the under-build Docker container to use the network specified by the
--docker-network
option.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
SAM CLI version: 1.36.0 OS: CentOS 7 AWS region: us-east-2 PackageType: Image