Hi people have been looking at this for far too long and need some help.
I have made a ASP.NET core website nothing fancy just the template that goes with VS 2017 (v 1.1). I publish the site using dotnet core cli and build an image using this dockerfile:
FROM microsoft/dotnet:1.1-runtime
COPY /Publish /dotnetapp
WORKDIR /dotnetapp
EXPOSE 8444
ENTRYPOINT ["dotnet", "Inqu.dll"]
When i run the image created with:
docker run -it <image_name:tag> -p 8444:8444
The image starts up waiting for request:
Hosting environment: Production
Content root path: /dotnetapp
Now listening on: http://*:8444
Application started. Press Ctrl+C to shut down.
but i can't reach the site and getting an ERR_CONNECTION_REFUSED when trying to access the site thought http://local-ip:8444/
I have modified the WebHostBuild to:
var host = new WebHostBuilder()
.UseKestrel()
.UseUrls("http://*:8444")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();
host.Run();
So it should listen to port 8444, I have also tried to set:
ENV ASPNETCORE_URLS http://*:8444
in the Dockerfile but it doesnt help.
I have some other images in docker up and running (gogs and mysql) and i can access them with my local ip:port with no problems, but i can't connect to the kestrel server.
Can somebody please help me out?
Was a stupid mistake arguments were in wrong order
docker run -it -p 8444:8444 <image_name:tag>
and it worked :\
Related
I'm trying to run a visual studio server and create a dockerfile. If you want to reproduce the script clone https://github.com/alessandriLuca/4Stackoverflow .
script.sh will build the docker container and run it sharing the port. The problem is that apparently i cant reach the port 8080 even if i exposed it. I solved on ubuntu with --network host but this option is not accessible for OsX or Windows.
Here is the last part of the dockerfile, that is related to visualStudio installation
COPY visualStudio /visualStudio
RUN cd /visualStudio/ && 7za -y x "*.7z*"
RUN dpkg -i /visualStudio/visualStudio/*.deb
COPY config.yaml ~/.config/code-server/config.yaml
EXPOSE 8080
CMD ["code-server","--auth","none"]
As you can see i use a config.yaml but that one is also not working since when i run the code-server that file is overwritten so, the port still remain 8080.
Thank you for any help
EDIT
You can find all files, included config.yaml here https://github.com/alessandriLuca/4Stackoverflow/tree/main/merged2_visualStudio
EDIT
I kind of solved it! Practically as you said was hosting on 127.0.0.1 instead of 0.0.0.0, soo i changed manually in config.yaml and now is working. The only problem now is to add this configuration directly in the dockerfile since, when I run the server he overwrite the config.yaml that I created. Does someone have any idea about this part?
I am trying to make my simple spring boot app to work on docker
I am running on windows 10, docker 2.2.0.5 engine 19.03.8
I tested simple nginx image and it working after start I am able to access it via "http//localhost:8000"
But when I am trying to run my app it is not working
this is my Dockerfile:
FROM openjdk:8-jdk-alpine
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
I set very basic application.properties file:
server.port=8080
spring.resources.static-locations:"file:./swagger-ui/"
then build and run with following commands:
docker build -t myapp-image .
docker run -p 8081:8080 myapp-image
docker container is running , I am able to ssh and when trying to curl some api on port 8080 all works or at least I am getting 404 error
tested telnet from my host to 127.0.0.1 8081 is accessible
but when trying to do localhost:8081/somepath getting "This page isn’t working error"
what am I missing here, please help?
Aim: I want to see my app running on the outside world.
My Dockerfile is as follows:
FROM node:8.1.0
RUN mkdir /app
WORKDIR /app
RUN npm install
EXPOSE 3000
docker build -name xyz . //ignore any mistakes coz it is working correctly.
docker run -d -p 8100:3000 --name server xyz
In order to run this on the user agent i.e chrome, should I write the url as follows?
ec2 ip: xx.xx.xxx.xx:8100 //is it all correct process from top to down?
When I ran xx.xx.xxx.xx:8100 on the browser the browser shows the site can't be reached.
I believe you missed the part where you need to open the port in the Inbound Rule of the EC2's Security Group. Please see photo below:
Then go to the port 8100 of your DNS or EC2's IP like xx.xx.xxx.xx:8100
I am trying out Docker with a small WebApi which I have written in dotnet core.
The Api seems to work fine because when I run it with dotnet run it starts normally and is reachable on port 5000. But when I run it in a Docker container it starts, but I cannot reach it on the exposed/mapped port. I'm running Docker on Windows 10 withing VirtualBox.
My Dockerfile looks like this:
FROM microsoft/aspnetcore-build:latest
COPY . /app
WORKDIR /app
RUN dotnet restore
EXPOSE 5000
ENV ASPNETCORE_URLS http://*:5000
ENTRYPOINT ["dotnet", "run"]
I am building the dontainer like this:
docker build -t api-test:v0 .
And run it with this command:
docker run -p 5000:5000 api-test:v0
The output of the run command is:
Hosting environment: Production
Content root path: /app
Now listening on: http://localhost:5000
I have also tried different approaches of binding the URL:
as http://+:5000, http://0.0.0.0:5000, http://localhost:5000, ...
via CLI parameters --urls / --server.urls
but without success. Does anyone see what I'm doing wrong or missing?
Now listening on: http://localhost:5000
Binding to localhost will not work for your scenario. You need to get the app to bind to 0.0.0.0 for the docker port forwarding to work. Once you do that, you should be able to reach the app on the VM IP, port 5000
Make sure your service is listening on all ports using http://*:500 or similar (if it prints localhost when running, it won't work).
If you set up your docker environment with VirtualBox and used e.g. docker-machine, you n need to use the IP address of the virtual machine that runs the docker containers. you can get the IP via docker-machine ip default.
I found a way round this. All you need to do is edit launchSettings.json change to "applicationUrl": "http://*:5000/" of your app setting. Build the image. Then run the image docker run -d -p 81:5000 aspnetcoreapp after it runs get ip address of the container docker exec container_id ipconfig. Then in browser http://container_ip:5000/api/values. For some reason it does not work http://localhost:81 still need to figure out why that is.
I had the same issue recently with Docker version 20.x. The comment above provided good lights. If anyone faces the same issue here is how I've solved: Edit launchSettings.json to
"applicationUrl": "http://localhost:5001;http://host.docker.internal:5001",
This will let you test your web API locally and also to be consumed from the container.
I've set up an Azure Container Service cluster, as shown here https://learn.microsoft.com/en-us/azure/container-service/container-service-deployment with SWARM. Then I've connect to it as shown here https://learn.microsoft.com/en-us/azure/container-service/container-service-connect.
I've installed docker for windows (I've shared drives) and the visual studio docker tools.
I've created the default ASP.NET Core app that has this dockerfile
FROM microsoft/aspnetcore:1.0.1
ENTRYPOINT ["dotnet", "MyTest.dll"]
ARG source=.
WORKDIR /app
EXPOSE 80
COPY $source .
I've changed it (because it doesn't do anything) to something that looks like :
FROM microsoft/aspnetcore:1.0.1
WORKDIR /app
EXPOSE 80
COPY out ./
ENTRYPOINT ["dotnet", "MyTest.dll"]
Then, I've opened a command prompt and moved to my root folder and i've done :
set DOCKER_HOST = tcp://localhost:2375
docker version
(docker version is OK)
then :
dotnet publish -c Release -o out
docker build -t testaspnetcore .
then :
docker run -d -p 8080:80 testaspnetcore
then :
docker ps
and I see the container in the list, but when I connect to my cluster ACS with SSH and I do
docker -H 172.16.0.5:2375 ps -a
I can't see my container in the cluster.
note : when I do docker ps on local, i can see in putty event log : Forwarded port closed due to local error: Network error: Software caused connection abort. Tried to turn of firewall, and many others things, but no results
How can I deploy to the swarm cluster my own image ?
There is a tutorial at https://learn.microsoft.com/en-us/azure/container-service/container-service-docker-swarm
With respect to your Putty problem it might me that you have Docker running on your client machine thus you have a port conflict. You can change the client port to something different to avoid this clash.