Curl not getting to rancher container hosted on windows - windows

I'm trying to setup Rancher container + import Raspberry PI 4 k3s cluster into it. Rancher runs on Windows 10, unfortunately for the final deliverable I must use Windows instead of Ubuntu or any other distro. Still I try configurations on Ubuntu 22.04 first and everything works fine on it.
I'm following instructions found on the internet and I managed to setup the cluster itself with no problem.
When I try to import RPi cluster into Rancher hosted on windows with following command generated by Rancher:
rpi#raspberry: curl -v --insecure -sfL https://[rancherIp]:8443/v3/import/[generated-config-file].yaml | kubectl apply -f -
I get following error:
* Trying [Windows IP]:8443...
* connect to [Windows IP] port 8443 failed: Connection timed out
* Failed to connect to [Windows IP]] port 8443 after 130858 ms: Connection timed out
* Closing connection 0
error: no objects passed to apply # this line is from kubectl
Every time, the curl times out after ~2 minutes and no yaml file is passed to the kubectl apply command and it fails. Since it works on Ubuntu, I wanted to ask folks familiar with similar efforts why curl times out on Windows.
All the devices are on the same network. Any advices highly appreciated.

Related

Connection refused from host into a linux container with Docker for Windows

I found a lot of material on this issue online, however I wasn't able to find a solution. Also majority of them are rather old (a few years) and things could have considerably changed meanwhile.
I have Docker Desktop Community v 2.3.0.3 running on my Windows machine and a simple container with Ubuntu and a Rails app running on localhost:5000 inside.
The container gets run using:
docker run -p 5000:5000 rails:6.0.3 foreman start
I would like to connect to the Rails app from my Windows host machine via browser, but connection gets refused.
The server is up and running:
> docker exec 3c167e206f60 wget localhost:5000
--2020-06-06 08:21:26-- http://localhost:5000/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:5000... connected.
HTTP request sent, awaiting response... 200 OK
Port forwarding doesn't seem to work correctly (run from WSL, but similarly from Windows via Chrome):
> wget localhost:5000
--2020-06-06 10:22:50-- http://localhost:5000/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:5000... failed: Connection refused.
It doesn't work when using container address instead of localhost, either:
> docker inspect --format '{{ .NetworkSettings.IPAddress }}' 3c167e206f60
172.17.0.2
> wget 172.17.0.2:5000
--2020-06-06 10:29:02-- http://172.17.0.2:5000/
Connecting to 172.17.0.2:5000... failed: Resource temporarily unavailable.
Also (as probably expected), I don't see any docker related entry in ifconfig (from WSL) or ipconfig (from Windows) output.
I also tried docker run --net host parameter, which didn't help either.
I would ideally prefer a solution which doesn't require me to modify the Windows host setup (network setup, etc), to avoid the possibility of breaking other scenarios.
I've been struggling with this issue for several days. What worked for me was to:
Uninstall Docker Desktop
Turn off the Hyper-V, Virtual Machine Platform, and Windows Hypervisor Platform via the Turn Windows Features On and Off control panel module
Reboot
Turn on all features in #2
Re-install Docker Desktop
This seems to reset all of the HyperV virtual networking interfaces. It's possible that uninstalling Docker Desktop isn't necessary but since it relies on at least some of these features I felt it wisest to do a complete cycle.

Connect to a MariaDB Docker Container in a own Docker network remotly

Hi what I am actually trying is to connect remotly from a MySQL Client in Windows Subsystem for Linux mysql -h 172.18.0.2 -P 3306 -u root -p and before that I started the Docker Container as follows: docker container run --name testdb --network testnetwork -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mysqlRootPassword -e MYSQL_DATABASE=localtestdb -d mariadb/server.
The purpose why I put the container in a own network, is because I also have a dockerized Spring Boot Application (GraphQL-Server) which shall communicated with this db. But always when I try to connect from my built-in mysql client, in my Windows Subsystem for Linux, with the above shown command. I got the error message: ERROR 2002 (HY000): Can't connect to MySQL server on '172.18.0.2' (115).
What I already tried, to solve the problem on my own is, look up whether the configuration file line (bind-address) is commented out. But it wont work. Interestingly it already worked to set up a docker container with MariaDB and connect from the outside, but now when I try exactly the same, only with the difference that I now put the container in a own existing network, it wont work.
Hopefully there some one out there which is able to help me with this annonying problem.
Thanks!
So far,
Daniel
//edit:
Now I tried the solution advice from a guy from this topic: How to configure containers in one network to connect to each other (server -> mysql)?. Futhermore I linked my Spring Boot (server) application with the "--link databaseContainerName" parameter to the MariaDB container.
Now I am able to start both containers without any error, but I am still not able to connect remotly to the MariaDB container. Which is now running in a virtual docker network with his own subnet.
I explored this recently - this is by design - container isolation. Usually only main (service httpd) host is accessible externally, hiding internal connections (hosts it communicates to deliver response).
Container created in own network is not accessible from external adresses, even from containers in the same bridge but other network (172.19.0.0/16).
Your container should be accessible on docker host address (127.0.0.1 if run locally) and mapped ("-p 3306:3306") port - 3306. But of course it won't work if many running db containers have the same mapping to the same host port.
Isolation is done using firewall - iptables. You can list rules (iptables -L) to see that - from docker host level.
You can modify firewall to allow external access to internal networks. I used this rule:
iptables -A DOCKER -d 172.16.0.0/12 -j ACCEPT
After that your MySQL containerized engine should be accessible using internal address 172.18.0.2 and source (not mapped) port 3306.
Warnings
it disables all isolation, dont't use it on production;
you have to run this after every docker start - rules created/modified by docker on the fly
not every docker container will respond on ping, check it from docker host (linux subsystem in this case) first, from windows cmd later
I used this option (in docker.service) to make rule permanent:
ExecStartPost=/bin/sh -c '/etc/iptables/accept172_16.sh'
For docker on external(shared in lan) host you should use route add (or hosts file on your machine or router) to forward 172.x.x.x addresses into lan docker host.
Hint: use portainer project (with restart policy - always) to manage docker containers. It's easier to see config errors, too.

Can't connect from outside of container to Clickhouse by HTTP on Mac OS

I'm trying to use ClickHouse with docker on Mac OS. I use next command:
docker run -d -p 8123:8123 --rm --name some-clickhouse-server -v /my/config/path/config.xml:/etc/clickhouse-server/config.xml --ulimit nofile=262144:262144 yandex/clickhouse-server:latest
Container successfully started, but when I try to connect to it by http curl 'http://localhost:8123' I have an error:
Failed to connect to localhost port 8123: Connection refused
When I connect to Clickhouse from Clickhouse-client (also using docker image) everything is OK
I ran Clickhouse-server image in -it mode, installed curl, started server and tried to connect clickhouse-server from inside of container, it's OK too
Also I tried to modify config.xml (which was copied from docker image) settings for listen_host (::, 0.0.0.0, ::1, 127.0.0.1)
and for every setting I tried to connect by curl for localhost, 127.0.0.1, 0.0.0.0 - nothing of this solved my problem
Normally, docker desktop write these details of host and container to /etc/hosts, after adding the clickhouse-service as follows has resolved this issue.
127.0.0.1 localhost clickhouse-service
I used Docker Toolbox on Mac OS (in conjunction with VirtualBox). So, I've migrated to Docker Desktop and this has solved my problem

Access a host from within a Docker container on Windows

I use Docker CE for Windows on latest Windows 10 and have built an image with a
script that runs a test against a web server.
(A litmus test suite for a WebDAV server to be exact, but I think the problem
is general.)
I run the web server on a Powershell console:
> wsgidav -p 8080 -H localhost
21:04:19.107 - <13348)> wsgidav INFO : Running WsgiDAV/3.0.0a3 Cheroot/6.4.0 Python/3.6.5
21:04:19.107 - <13348)> wsgidav INFO : Serving on http://localhost:8080 ...
From another Powershell console, I run my script in a Docker container (using FROM alpine).
The script starts and tries to access the endpoint, but does not succeed:
> docker pull mar10/litmus
> docker run --rm -p 8080:8080 mar10/litmus http://gateway.docker.internal:8080
-> running `basic':
0. init.................. FAIL (connection refused by `gateway.docker.internal' port 8080: Operation timed out)
I tried so far
Using the gateway.docker.internal hostname
using -p PORT:PORT
using --net=host
restarting the docker daemon (which interestingly sometimes also was neccessary to
fix timeouts in docker pull)
different IP addresses for the web server (127.0.0.1, localhost, 0.0.0.0, local IP)
Nothing worked so far (although the failure message may be different).
Maybe I just missed a working combination of the above, or any other trick?
FWIW, I was able to solve it by building the container with the --network host option and use a real IP of the client (instead of localhost or 0.0.0.0).
Details here: https://hub.docker.com/r/mar10/docker-litmus/

Docker and Windows - Problems with SSH on default container

i'm new to Docker and i've just intalled Docker ToolBox 1.11.1 on my Windows 7 (64 bit).
When running Quickstart Terminal i've got problems with creating default container.
After reading a bunch of forums i've invoked :
docker-machine rm -f default
docker-machine --debug create -d virtualbox default
But still without result. Full logs from last operation are :
https://gist.github.com/anonymous/117e302c047492170a6f0c7d4e79199a
They end up with phrase :
"(default) DBG | Error dialing TCP: dial tcp 127.0.0.1:49659: connectex: No connection could be made because the target machine actively refused it."
I've have no idea how to fix that. Can someone help me ?
In windows and Mac OS Docker run in a virtual machine. When you install Docker using the Docker Toolbox, it takes care of install Virtual Box, create a “default” virtual machine and configure it to run a Boot2Docker image.
With the command:
docker-machine rm -f default
you are removing this default VM. Then running the command:
docker-machine --debug create -d virtualbox default
you are creating a new VM called “default”, so you are not creating or starting any default windows container.
"Actively refused it" means that the host sent a reset instead of an ack when you tried to connect. Please, check the firewall or the proxy configuration because this is a communication problem.
Hope this can help.

Resources