Can't send HTTP Request from inside a docker container - docker

I have a java application as JAR. This JAR application runs fine from my machine, meaning it can send and receive HTTP Requests to and from an API Endpoint (let's call this endpoint example.com/api/).
And then i built a docker image of this JAR Application, and tried to run the image as container from my docker desktop. But then i got this error.
the error i got
it seems like my application cant reach the url from inside the docker container. I tried to set the proxy in Settings -> Resources -> Proxies -> Manual proxies configuraton, and put my company proxy since i'm inside my company network. But still it doesn't work.
I tried to google this problem but almost nothing shows up (anything that shows up have little correlation with my problem). Anyone knows what seems to be the problem? What should I do?

First check if your container is able to communicate with the endpoint. Ping or curl it from the container shell. If you use proxy, set environment variables in container:
export http_proxy=http://server-ip:port
export https_proxy=https://server-ip:port

Related

Local IMAP server on docker

I want to setup a local IMAP server within my home network for archiving emails. The server does not need to be accessable via the internet. Therefore I can pass on a secured access via SSL (If this makes it easier). I want to integrate the server in my current docker setup. So the server has to run within a docker container.
I already tried the following containers:
https://hub.docker.com/r/blackflysolutions/dovecot
https://hub.docker.com/r/dovecot/dovecot
https://hub.docker.com/r/mailu/dovecot
https://hub.docker.com/r/mailcow/dovecot
https://hub.docker.com/r/eilandert/dovecot
But i could not get any of them to run. At the same time none of them have a forum or anything where I can put a question. Two of them (mailu/dovecot and mailcow/dovecot) are part of a bigger mailserver package. Which I do not need, I only want a IMAP server to put some email locally. But I tried them anyway.
Does anyone know how to get any of those to run? Or suggest me another stable docker container solution.

How to connect via http instead of default https on nifi docker container

I am currently running latest versions Nifi and Postgresql via docker compose.
as of 1.14 version update of Nifi, when you accesss the UI on web it connects via https, thus asking you for ID and Password every time you log in. Its too cumbersome to go to nifi-app.log file and look for credentials every time I access the UI. I know that you can change the setting where it keeps https as the default method but I am not sure how to do that in a docker container. Can anyone help me with this?
You could use some env like AUTH in the documentation
You can find the full explanations here

.NET Core Worker Service (running in Docker) cannot connect to local REST API using HTTPS

As the title states, I'm trying to figure out how I can get my .NET Core worker service deployed inside a Docker container to communicate with a REST API on my local machine (Docker host) via HTTPS.
NOTE: The Docker container is able to communicate with the REST API via plain-old HTTP just fine, so this seems to purely be an issue with HTTPS/SSL.
For background, I have a ASP.NET Core REST API deployed on my local machine via IIS. I have one binding for HTTP (port 8001) and one for HTTPS (port 8101). Additionally, said API also interfaces with my companies (model) IdentityServer instance.
Additionally, I have a .NET Core worker service which communicates with the aforementioned REST API (using an HttpClient under the hood). I've packaged this into a Docker image/container (using a Dockerfile, etc.).
When I run the container using the HTTP (not HTTPS) endpoints, everything is fine and the container is able to interface with the REST API on the local machine (provided I use host.docker.internal in place of localhost in URLs).
However, when I switch to HTTPS, things go haywire and I receive the following error:
System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
I searched around for solutions but nothing seems to be working, but maybe I'm doing something wrong.
I've tried exporting (via Windows Certificate Manager) all the relevant certificates I could come up with as .cer files, changing their extensions to .crt and adding them to the Docker container via the Dockerfile:
COPY FooBar.crt /usr/local/share/ca-certificates/
RUN update-ca-certificates
ENTRYPOINT ["dotnet", "My.Project.dll"]
(Omitted the extraneous build/publish steps as I know those are working fine, but this snippet is part of a larger multi-stage Dockerfile).
NOTE: update-ca-certificates did recognize the certificates, so I'm under the impression they were added. I thought that there might have been an issue since I'm using a multi-stage Docker build, but even adding the certificates right before the ENTRYPOINT seems to make no difference.
I'm honestly not sure what else it could be at this point (or if my use case is even supported).

Nginx reverse proxy with node docker seems not working

I set up a docker containing a nodejs server and which receives arguments from a path. I can communicate well with my docker instance when I run a curl command (I have an error message, but this is normal)
I'm trying to communicate with my docker instance from the outside with my Nginx server, but I'm having some problems.
Indeed, when I enter the access url, I get a 404 error. My configuration file looks like this.
when I try I go to the access url, I do have a 404 error.
My concern is on the "location" part of my configuration, but I don't really see how to solve the problem. If you have any leads, I'll take them :)

Docker cannot acces registry from openshift

Here is my whole scenario.
I have a RHEL 7.1 vmware image, with the corporate proxy properly configured, accessing stuff over http or https works properly.
Installed docker-engine, and added the HTTP_PROXY setting to /etc/systemd/system/docker.service.d/http-proxy.conf. I can verify the proxy setting is picked up by executing:
sudo systemctl show docker --property Environment
which will print:
Environment=HTTP_PROXY=http://proxy.mycompany.com:myport/ with real values of course.
Pulling and running docker images works correctly this way.
The goal is to work with the binary distribution of openshift-origin. I downloaded the binaries, and started setting up things as per the walkthrough page on github:
https://github.com/openshift/origin/blob/master/examples/sample-app/README.md
Starting openshift seems to work as I can:
* login via the openshift cli
* create a new project
* even access the web console
But when I try to create an app in the project (also via the cli):
oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-hello-world.git
It fails:
error: can't look up Docker image "centos/ruby-22-centos7": Internal error occurred: Get https://registry-1.docker.io/v2/: dial tcp 52.71.246.213:443: connection refused
I can access (without authentication though) this endpoint via the browser on the VM or via WGET.
Hence I believe DOCKER fails to pick up the proxy settings. After some searching I also fear if there are IPTABLES settings missing. Referring to:
https://docs.docker.com/v1.7/articles/networking/
But I don't know if I should fiddle with the IPTABLES settings, should not Docker figure that out itself?
Check your HTTPS_PROXY environment property.

Resources