1

I'm attempting to run a asp.net core application from a raspberry pi using docker, I think I have the main parts down. I have a repository on github that is a simplistic asp.net core project. I have setup an account on docker cloud which build everytime I push to my github repo.

I have docker pulled my repository onto my pi: screenshot of docker image being on pi

I run the command: docker run -d -p 8080:80 joro550/radiusnet --network=host and I can see that it is running: image of docker image running

But when I go to my pi's ip address on port 8080 then I get this: Connection refused screen shot

When I've been searching around for this people have suggested adding these flags (which I have tried and come up with the same results:

  • adding --network=host to the docker run command
  • adding -it to the docker run command
  • Adding Expose 80 into the docker file

I think at this point I'm at a bit of a lose as to how to access this thing. The docker documentation does suggest running

`docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" myapp`

If I'm using windows 10 Nano containers, which I don't believe I'm using but when I run this command I get a resounding <no value>

Cutting it back to docker inspect -f "{{ .NetworkSettings.IPAddress }}" myapp gives me a different ip address to my ips internal ip address, which I've tried on port 8080 and get the same result

Doing a curl on both addresses gives me the same result of connection refused: curl failing on ip address

Here's my docker file for anyone interested:

FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app

# copy csproj and restore as distinct layers
COPY /src ./
RUN dotnet restore

# copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out -r linux-arm

# build runtime image
FROM microsoft/dotnet:2.0.0-runtime-stretch-arm32v7
WORKDIR /app
COPY --from=build-env /app/src/RadiusNet.Web/out .
EXPOSE 80
ENTRYPOINT ["dotnet", "RadiusNet.Web.dll"]

If any more information is needed please ask, I'm pretty new to Docker so I just did a bit of a knowledge dump of my current situation.

Link to github project (if it's needed): https://github.com/joro550/RadiusNet

Any help - at this point will be greatly appreciated

  • Comments are not for extended discussion; this conversation has been moved to chat. – terdon Feb 12 '18 at 9:52
2

A couple of remarks first

  • in Dockerfile, "EXPOSE 80" is used by "docker run -P", "publish all"
  • it's no use publishing a port the docker isn't servicing (eg. "-p 8000:80" when a service is running on port 5000

The listening ports are reported by "docker port", but they don't guarantee they will be serviced.

# docker run --name radiusnet -p 8001-8009:5000/tcp  radiusnet
Hosting environment: Production
Content root path: /app
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

# docker port radiusnet
5000/tcp -> 0.0.0.0:8001

The proof of the pudding ...

# wget -O /tmp/test.html  http://localhost:8001/
--2018-02-08 16:22:46--  http://localhost:8001/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:8001... connected.
HTTP request sent, awaiting response... 

If this fails, the wrong ports have been published.

When started with "--network host", "docker port" may report nothing, while the docker is servicing nicely. "lsof" can help.

# docker run --name radiusnet --network host  radiusnet
Hosting environment: Production
Content root path: /app
Now listening on: http://localhost:5000

# docker port radiusnet 

# ps -ef | grep dotnet
root       540 27973  0 16:46 pts/2    00:00:00 grep dotnet
root     32452 32437  7 16:37 ?        00:00:43 dotnet RadiusNet.Web.dll

# lsof -Pn -p 32452 | grep LISTEN
dotnet  32452 root  368u     IPv4     106845      0t0    TCP 127.0.0.1:5000 (LISTEN)
dotnet  32452 root  383u     IPv6     106854      0t0    TCP [::1]:5000 (LISTEN)

# wget -O /tmp/test.html  http://localhost:5000/       
--2018-02-08 16:56:27--  http://localhost:5000/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:5000... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘/tmp/test.html’

All is well that ends well.

  • I wish I could upvote you more than once, thank you, from the bottom of my heart!! – Mark Davies Feb 8 '18 at 22:03
  • You're welcome, it was an interesting exercise. But what was wrong with your setup? – Gerard H. Pille Feb 9 '18 at 1:25
  • I'll probably figure that out and add an answer of my own when I have time – Mark Davies Feb 9 '18 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.