Docker Component with two ports and one is not bound - docker

I tryed to creat a mssql Database in a Doker Container. When I try to connect to the Database with Azure Data Studio i get following Error:
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)
I already tryed to set Encrypt=false and Trust server certificate=true.
I found out that my Container has for some reason two Ports and one of them is not bound
Docker Component with two Ports Picture
Here is the cmd command i used to creat the Container:
docker run -p 1488:1488 --name 'story-world-sql' -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=shjksdhf///47238' -e 'MSSQL_PID=Express' -d mcr.microsoft.com/mssql/server:2022-latest

Related

Why is my docker registry refusing connections from VMs in my local network but not the host?

For context - I am attempting to deploy OKD in an air-gapped environment, which requires mirroring an image registry. This private, secured registry is then pulled from by other machines in the network during the installation process.
To describe the environment - the host machine where the registry container is running is running Centos 7.6. The other machines are all VMs running Fedora coreOS in using libvirt. The VMs and the host are connected using a virtual network created using libvirt which includes DHCP settings (dnsmasq) for the VMs to give them static IPs. The host machine also hosts the DNS server, which, as far as I can tell is configured properly, as I can ping every machine from every other machine using its fully qualified domain name and access specific ports (such as the port the apache server listens on). Podman is used instead of Docker for container management for OKD, but as far as I can tell the commands are exactly the same.
I have the registry running in the air-gapped environment using the following command:
sudo podman run --name mirror-registry -p 5000:5000 -v /opt/registry/data:/var/lib/registry:z \
-v /opt/registry/auth:/auth:z -v /opt/registry/certs:/certs:z -e REGISTRY_AUTH=htpasswd \
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/registry.pem -e REGISTRY_HTTP_TLS_KEY=/certs/registry-key.pem \
-d docker.io/library/registry:latest
It is accessible using curl -u username:password https://host-machine.example.local:5000/v2/_catalog which returns {"repositories":[]}. I believe this confirms that my TLS and authorization configurations are correct. However, if I transfer the ca.pem file (used to sign the SSL certificates the registry uses) over to one of the VM's on the virtual network, and attempt to use the same curl command, I get an error:
connect to 192.168.x.x port 5000 failed: Connection refused
Failed to connect to host-machine.example.local port 5000: Connection refused
Closing connection 0
This is quite strange to me, as I've been able to use this method to communicate with the registry from the VMs in the past, and I'm not sure what has changed.
After some further digging, it seems like there is some sort of issue with the port itself, but I can't be sure where the issue is stemming from. For example, If I run sudo netstat -tulpn | grep LISTEN on the host, I receive a line indicating that podman (conmon) is listening on the correct port:
tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN 48337/conmon
but if I test whether the port is accessible from the VM, (nc -zvw5 192.168.x.x 5000) I get a similar error: Ncat: Connection refused. If I use the same test on any of the other listening ports on the host, it indicates successful connections to those ports.
Please note, I have completely disabled firewalld, so as far as I know, all ports are open.
I'm not sure if the issue is with my DNS settings, or the virtual network, or with the registry itself and I'm not quite sure how to further diagnose the issue. Any insight would be much appreciated.

Unable to connect to a Linux-based SQL Server 2017 Latest database container with SSMS

A RESTFUL API depends on a SQL Server database so I am trying to use a SQL Server Linux container as shown here.
API app dependents on a database (mcr.microsoft.com/mssql/server:2017-latest-ubuntu), so I ran this docker command in Windows PowerShell:
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=yourpssword" -e "MSSQL_PID=Express" --name sql1
-p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest-ubuntu
Linux -DB Container is created successfully and running as below by Docker ps -a in Windows PowerShell
https://uploads.disquscdn.com/images/9221f417a654aca4ec2fe923ca3743c6f447772bd8b853583fe2312ea012aef2.jpg
But when I tried to connect to the newly created database container with SSMS, I get this error:
https://uploads.disquscdn.com/images/8c09b0d4c863769f4c810d2a167ce17cc2227a7e63b57a58504d5159a6eb614a.jpg
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.
Please help - am I missing something else?
Thanks,
After spending some time, i found out below web page, it helps me to resolve the above problems..
https://tomssl.com/running-microsoft-sql-server-on-a-linux-container-in-docker/
I am using Windows 10 pro and docker host for development envr. For connecting sql-db
Linux based container with SSMS tool, we Need to change docker DB port so we delete the existing container and again recreate sql-db container as below and run command at power-shell
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Pa$$w0rd2019' -e 'MSSQL_PID=Developer' -p 1401:1433 --name sql2017 -d microsoft/mssql-server-linux:2017-latest
Now i am able to connect to docker sql DB by SSMS as below
Thanks,

Docker, MS SQL Server, SMMS not connecting unless I stop any local SQL Server Instance

I'm trying to connect to SQL Server in a docker container via SQL Server Management Studio.
My docker SQL container instance is running with the following command:
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Pizza1234$" -p 1433:1433 --name sqlserver-test -d mcr.microsoft.com/mssql/server:2017-latest
I then try to connect to the SQL Server in the docker container using the server name: localhost, 1433
I was unable to connect SSMS to the instance of SQL Server in the sqlserver-test container but then discovered that if I stop my local instance then SSMS will connect to the SQL server instance in docker which would suggest that SQL is attempting to find a local localhost instance and only when it cannot find one it points to the one docker is hosting.
Can I explicitly set a name for the docker instance or can I include an IP address in the server name when trying to connect to the instance in docker via ssms? I can connect when both are running via bash run from docker so I think it is something missing from my server name when using SSMS.
change the mapped port on the host and you should be good to go. The 2 instances are trying to get hold of the port 1433 and only the first will manage to be satisfied.
You can replace the -p 1433:1433 with -p 2434:1433 and change the connection string on the client.

Meraki API connection refused from test server

I have a java application and it can successfully connect to api.meraki.com in my local machine but when I deploy my java application to the test server,
the application which lives in a docker container can not connect to api.meraki.com.
In the host machine, I can also curl the api.meraki.com but inside my docker container (docker exec -it xxx /bin/bash), I can't curl as it gives a connection refused error.
I tried to use a new API key to test server but it is still giving connection refused error. I also tried to allow my test server from Meraki dashboard but no success.
Any ideas that what is the problem and the solution?
edit: i run container with
docker run -dit -p 9078:8080 -e "SPRING_PROFILES_ACTIVE=prod,swagger,preprod" --name abc -v /etc/localtime:/etc/localtime:ro -v /etc/hosts:/tmp/hosts example.com.com:5000/abc:v1.12.5
and in my container when i run getent hosts api.meraki.com resolves dns as:
209.206.57.71 mun211.meraki.com api.meraki.com emea.api.meraki.com n23.meraki.com
test server was behind proxy and it was not configured, configuring both container and the application resolved the problem. (i think the application is connecting other service by bypassing the proxy.

Unable to register docker selenium remote node to selenium hub remote host with docker

I'm trying to connect the docker selenium remote node to remote docker hub, But it's not connecting, it shows the connection refused exception in Grid console(http://localhost:4444/grid/console) as in below screeshot.
Grid Screenshot:
The command I used to run the Hub on Machine A:
Hub:
docker run -d -p 4446:4444 --name selenium-hub -P selenium/hub
and command I used to register Node in Machine B on same network is:
docker run -d -e HUB_PORT_4444_TCP_ADDR=10.7.30.9 -e HUB_PORT_4444_TCP_PORT=4444 selenium/node-firefox-debug:latest
But getting an error like this:
DefaultRemoteProxy unknown version,Connect to 172.17.0.2:5555 [/172.17.0.2] failed: Connection refused (Connection refused)
I am not an expert on docker, but it looks like you haven't linked both the hub and the node using the --link option. Without that linking the containers I don't think will talk to each other which explains why your registration itself is failing.
Can you please use the --link option and try again as detailed here.
All said and done, it looks like the option --link is getting deprecated in docker and there are alternatives for that. Please refer to this StackOverFlow post for understanding the alternatives.

Resources