Docker container exits immediately in Linux Server
Asked Answered
H

0

6

I have built an image with simple ASP .NET Core 2.0 App in Alpine Docker. When I run the Linux container on Windows Power-Shell, everything is fine. But if I run the Linux container on a Linux Server in PuTTY, the container will immediately exit with code 139. I have used the following conmmand:

docker run -it -d -p xxxx:80 imageName

output:

510e77c3899696823d4f1fba135cbaff3f8b4232deb1a73d41963fc3a8058d81

run without -d

Hosting environment: Production
Content root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.

OS: Win 10

Docker Version:

Client:
 Version:       17.12.1-ce
 API version:   1.35
 Go version:    go1.9.4
 Git commit:    7390fc6
 Built: Tue Feb 27 22:15:20 2018
 OS/Arch:       linux/amd64

Server:
 Engine:
  Version:      17.12.1-ce
  API version:  1.35 (minimum version 1.12)
  Go version:   go1.9.4
  Git commit:   7390fc6
  Built:        Tue Feb 27 22:17:54 2018
  OS/Arch:      linux/amd64
  Experimental: false

Is there a way to keep the container alive? Did I miss anything important? Any ideas would be appreciated!

Update Dockerfile:

#build image
FROM microsoft/dotnet:2.1-sdk as builder
WORKDIR /app

COPY *.csproj .
RUN dotnet restore

COPY . .
RUN dotnet publish --output /out/ --configuration Release 

# runtime image
FROM microsoft/dotnet-nightly:2.1-runtime-alpine AS runtime
RUN apk add --no-cache libuv \
 && ln -s /usr/lib/libuv.so.1 /usr/lib/libuv.so
ENV ASPNETCORE_URLS http://+:80

WORKDIR /app
COPY --from=builder /out .
ENTRYPOINT ["dotnet", "WebAppHelloWorld.dll"]
Herman answered 20/3, 2018 at 16:29 Comment(4)
It depends on what's running in your container and what your container configuration is. Exit code 139 means your program exited with signal 11/SIGSEGV which is a segmentation fault.Riverhead
I think 139 could also mean you're asking it to run something that isn't compatible with the OS (like running something compiled for Windows on Linux). Try running it without -d and update your answer with the output. It would also be nice to see your Dockerfile.Constitutionality
@Constitutionality I have updated my post about the output and the Dockerfile.Herman
.Net Core 2.1 has been out of beta for some time now, switch to a stable image and tell us if it fixes your issueGemina

© 2022 - 2024 — McMap. All rights reserved.