I’m building and testing a docker container in CodeBuild running a .NET 8 asp web app with kestrel configured to listen on any IP on port 5000. When I build and test locally (using the same set of steps as in CodeBuild), everything is great. When I run it in the CodeBuild environment, the container builds and runs, but the port is missing. When I run a netstat -tulnp
inside the container, there are no listening ports listed. Curling http://localhost:5000/
fails.
I’m starting the container in CodeBuild like this: docker run --name app --detach -p 5000:5000 repo/app:latest
. I’m then sleeping 10s and running some tests. I can see the actual process is running in the container through ps
.
[Container] 2024/06/06 03:02:45.740997 Running command docker exec -i app sh -c "ps"
PID USER TIME COMMAND
1 root 0:00 /var/www/app/web
23 root 0:00 ps
[Container] 2024/06/06 03:02:45.851668 Running command docker exec -i app sh -c "netstat -tlpn"
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
I’m at a loss. I’ve also tried setting --network host
with no difference. From everything I’ve read, this should work. I’m not sure if this is a dotnet problem with Kestrel running in CodeBuild or a docker problem with the CodeBuild environment.