I am having trouble connecting to a Wildfly server running in a Docker Desktop container. My Dockerfile is like so:
FROM jboss/wildfly:9.0.1.Final
COPY ./standalone-template.xml /opt/jboss/wildfly/standalone/configuration/standalone.xml
COPY ./MyApplication.war /opt/jboss/wildfly/standalone/deployments/MyApplication.war
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]
The server seems to start successfully, and at the end of the output from the CMD running docker run -it mydockerimage I see this output:
19:20:21,260 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 62) WFLYUT0021: Registered web context: /MyApplication
19:20:21,338 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "MyApplication.war" (runtime-name : "MyApplication.war")
19:20:21,568 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0061: Http management interface listening on https://0.0.0.0:9993/management
19:20:21,569 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0052: Admin console listening on https://0.0.0.0:9993
However, I am not able to connect to the server's admin console or the application from my machine's browser, I get ERR_CONNECTION_REFUSED. When I modify the docker run command to be docker run -it -p 9993:9993 mydockerimage I am able to connect to the admin console, but I can't do the same for the application itself. Normally for an https Wildfly server I wouldn't use any port when trying to connect through the browser, but trying to do https://localhost/MyApplication fails.
What should I change to allow connection to the "MyApplication" web context?
You need to include port 8080 in run command
docker run -it -p 8080:8080 -p 9993:9993 mydockerimage
and access your application at not https://localhost/MyApplication but at https://localhost:8080/MyApplication, or any other port that you choose in -p 8080:8080 for host port.
Related
I am very new to docker and Nifi so please understand if my question doesn't sound refined.
When I downloaded Nifi from official apache nifi website and fired it up, it was accessible via http://localhost:8443/nifi
But when I created a docker container using the following command
docker run -itd -p 8433:8080 --name nifi apache/nifi
it runs without a problem but it's not accessible via web UI
When I used
docker logs d7 | grep "JettyServer"
2022-07-07 23:17:13,334 INFO [main] org.apache.nifi.web.server.JettyServer NiFi has started NiFi has started. The UI is available at the following URLs:
2022-07-07 23:17:13,334 INFO [main] org.apache.nifi.web.server.JettyServer https://d723418f https://d723418f16d5:8443/nifi
above message was shown, which to my understanding it means that Nifi is running.
I have tried
-localhost:8433
-host IP:8433
-bridge network IP:8433
but none of those work.
Is this possibly because of the update on version 1.14.0 since it accesses UI via https rather than http and requires ID and password now ?
Or am I just missing something very simple?
Thank you all for your help in advance.
By default nifi listening only 8443 port (and using HTTPS connection)
If you want to connect using unsecure HTTP, you need to set HTTP port:
docker run -itd -p 8443:8080 -e NIFI_WEB_HTTP_PORT=8080 --name nifi apache/nifi
In this case HTTPS connection will be disabled and you will be able to connect with http://localhost:8443/nifi instead of secured HTTPS
* It is not possible to activate both 8080 (HTTP) and 8443 (HTTPS) connection at same time. You have to edit container entrypoint
script (/opt/nifi/scripts/start.sh) to activate both connections
I changed the port setting to 8443:8443 and added /nifi to the URL and it started working
I have started my .net core 3.1 web app under docker container and I'm having info from docker desktop client
Now listening on: http://[::]:80
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: /app
My controller looks like this
[Route("hello/[controller]")]
public class WorldController : ControllerBase
{
[HttpGet]
public IActionResult Get()
{
return Ok();
}
}
since my container is running on port 80 I'm trying to access controller action using
http://localhost/hello/world
but I'm getting HTTP Error 404.0 - Not Found
Am I missing something? Any suggestions?
Update:
Dockerfile
...
ENV ASPNETCORE_URLS http://*:57362
EXPOSE 57362
Even though I'm explicitly exposing 57362 docker still gives the message Now listening on: http://[::]:80
You can change the port ASPNETCORE will listen with the following directive in the Dockerfile:
ENV ASPNETCORE_URLS=http://+:80;https://+:443
If you want to change the default HTTP port to be 57362 you should do:
ENV ASPNETCORE_URLS=http://+:57362
After building the docker image, the application will run under port 57362 inside the container. To forward any port of your computer to the container port you need to run the container with the -p parameter as follows:
docker run -tid -p <host_port>:<container_port> my_image:<my_tag>
In your case it should be the following:
docker run -tid -p 80:57362 my_image:<my_tag>
If you're running this script on Windows on Docker for Desktop, it will only allow the binding of port 80 from an elevated prompt. If not running on an elevated prompt you can change it to port 8080 or any other.
You will need to map port 80 to 57362. This would look something like this inside a docker-compose.yml file if you have a docker-compose file thats to say and using the docker-compose up -build command
ports:
80:57362
I'm running an Aurelia app inside of the standard node docker container and it is listening on port 8080. Within the container, I have tested that it's running using curl; and it responds with the expected HTML. But I cannot reach the app via the mapped port on the host (outside the container).
I'm running the following command to start the container
$ docker run -it --rm -p 8080:8080 -v ${PWD}:/app node bash
Then inside the container, I install the cli and create a new app
# npm install -g aurelia-cli
# au new
After creating a default app, I cd into the app directory and run the app.
# au run
As I said above, I can verify the app is running using curl http://localhost:8080. However, on the host, I cannot access the app:
$ curl http://localhost:8888
curl: (52) Empty reply from server
Originally, I thought this was a docker problem. See this question. But it turns out that Aurelia is listening on localhost rather than 0.0.0.0.
Running Aurelia with the host option set allows the server to listen on 0.0.0.0, so it will map properly in a docker container.
au run --host 0.0.0.0
I have successfully built my web app image and ran a container on my server, which is an EC2 instance, with no error at all, but when I tried to access the web page it returned no connection, even though I accessed through the binded port of the host server. The build and run processes gave absolutely no error, either build error or connection error. I'm new to both Docker and AWS, so I'm not sure what could be the problem. Any help from you guys is really appreciated. Thanks a lot!
Here is my Dockerfile
FROM ubuntu
WORKDIR /usr/src/app
# install dependencies, nothing wrong
RUN ...
COPY...
#
# exposed ports
EXPOSE 5000
EXPOSE 5100
CMD ...
Docker build
$ sudo docker built -t demo-app
Docker run command
$ sudo docker run -it -p 8080:5000 -p 808:5100 --name demo-app-1 demo-app
I accessed through the binded port of the host server.
It's mean the application is running, and you're able to access using curl localhost:8080.
Now there are mainly two-issue if you're able to access the application after doing ssh to EC2 instance and verify the application responding on localhost of EC2.
Security group not allowing connection on the desired port, allow 8080 and the check
The instance is in private subnet, you can verify the instance.
I have run the following command to have a Docker application (ASP.NET Core) run on Windows desktop:
docker run --name eshopweb --rm -it -p 8000:5106 web
The console outputs the following:
Hosting environmnet: Production
Context root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
When visiting the following URL, localhost refused to connect.
http://localhost:5106/
How can a Docker application be viewed in the browser?
According to the output, the application is listening on 80;
You need to expose the port 80 of your container.
Do something like:
docker run -dit -p 8000:5106 -p 10080:80 --name eshopweb web
And then try: http://localhost:10080
8000 is your external port while 5106 is internal port of the container. Try http://localhost:8000/