How to connect to SQL Server hosted on Docker in Azure Ubuntu VM - azure

I have installed SQL Server 2019 docker on Azure Ubuntu VM. The container is up and running. However, I cannot connect to it using SSMS from outside the VM. While running the container I used port 1450 to map to 1433. Also, I have configured the NSG to allow the traffic.
Still, I have no luck.
iptables -L
NSG
Thanks

To run SQL Server through Docker on Ubuntu, you can follow the steps here:
Pull the docker image to your Ubuntu host:
docker pull mcr.microsoft.com/mssql/server:2019-CTP2.2-ubuntu
run the image through the docker command:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=azureUser#2018' -p 1450:1433 -d --name mssql mcr.microsoft.com/mssql/server:2019-CTP2.2-ubuntu
check the container if it runs well, you do this through the docker command:
sudo docker exec -it mssql /opt/mssql-tools/bin/sqlcmd \
-S localhost -U SA -P '<YourStrong!Passw0rd>'
open the port 1450 in the NSG associated with your VM
connect the SQL Server through the SSMS like this:
Note: If you open the firewall in the Ubuntu VM, you also need to open the port in the firewall.
You can find the Docker image information in Microsoft SQL Server and more details about Run && Connect the SQL Server image with Docker.
Update:
When you check the NSG rules, I suggest you can go into the VM networking, it will show all the NSGs that associated with the subnet and NIC. If allow port, you should add the rule to both NSG or change the NSG as the same, then you can just add the rule to only one NSG. Check the NSG rule as below:

Related

No Internet Access In Docker Container When Connected to Cisco AnyConnect VPN

I am connected to a corporate VPN and need to be able to run docker containers while the VPN is connected due to the fact that the container needs to be able to access corporate endpoints. However, when I am connected with AnyConnect VPN, docker has no internet access at all. Neither to our corporate endpoints or the internet.
I am running CentOS7 as my host operating system.
A simple way to reproduce this issue is to install a minimal linux distro, install AnyConnect VPN, connect to vpn and try to run the following docker container:
docker run -i -t ubuntu:14.04 /bin/bash
Once inside the container I try to ping google dns
[###]$ ping 8.8.8.8
There will be no response. If I disconnect from AnyConnect VPN and retry the above, I get a ping response.
How can I fix this issue?
Ping outside and internet access are different. You could access internet but could not ping as limit by your corporation network. I suggest running busybox
docker run -it --rm busybox
and check the dns setup inside
cat /etc/resolv.conf
From there you may see list of nameserver ip addresses. Now you could try to ping those to make sure they are reachable from inside. If not, you could try
traceroute 1.2.3.4
to see how far you could go from inside container, the first 2 lines should be ip of docker and the host machine, and then the ip of your corporation network
1 172.17.0.1 (172.17.0.1) 0.016 ms 0.011 ms 0.009 ms
2 10.1.249.4 (10.1.249.4) 38.487 ms 35.697 ms 35.558 ms
Usually it's problem of the nameserver generated inside /etc/resolv.conf
file. If it's the case, then you need to check /etc/resolv.conf
in the host machine and update the docker setup to generate the nameservers correctly inside container.
After you make a change to the network interfaces, you often need to restart the docker engine to rebuild all of the routes and iptables entries. With Linux and systemd, use:
systemctl restart docker

Accessing docker container running in remote linux machine from a windows browser

I have a remote ubuntu machine with docker installed and a container is running on that, i want to access it from my windows machine through a browser, i can connect to the ubuntu remote machine from my windows machine through putty, is there any way, i would be able to achieve this, any helps or leads in this case will be highly appreciated?
When you start the container, you'll need to publish the port that you want to connect to using the -p flag. Here's an example from the Docker documentation that publishes port 80 in the container to port 80 on the host (you can map to a different port if you'd like):
$ docker run -d -p 80:80 my_image service nginx start
See https://docs.docker.com/engine/reference/run/#expose-incoming-ports

Docker cannot access mariadb server

I am newbie on docker.
I want to migrate my nodejs app to docker, and existing database already installed on server (172.17.2.1). I set mariadb host 172.17.2.1 on my nodejs config.
After that, I created an images and run with :
docker run -p 3009:3009 -d my-node
actually its already running, but when I tested to open by browser, I got an error that my app cannot connect to 172.17.2.1 (connecting to database).
I try to create bridge IP (172.17.2.135) and make a same subnet, but still got a same error.
My images on docker inside doesn't know 172.17.2.1 on my LAN.
Please help me,
I use windows 10 environment
You have two options to allow your container to reach an external server:
Run your docker container on your host network:
docker run -p 3009:3009 --network host -d my-node
This way your container will be able to reach anything reachable from your machine
create a network bridge: in this case docker will route the traffic from the container to the external server. the bridge IP can't be your docker machine IP as you tried to do.

No response from VM Scale Set

I created a VM ScaleSet from a custom image where Docker is pre-installed. For testing, I just run on all available VMs this command: sudo docker container run -d -p 80:80 seqvence/static-site (just showing a simple static site on port 80).
However, I first created a healthProbe (just checking for tcp:80). Then I created a loadbalancing rule for port:80 -> backend port:80. And of course my LoadBalancer has a backend pool containing my VMs of my ScaleSet.
But when I now navigate to myvmss.westeurope.cloudapp.azure.com I get ERR_CONNECTION_TIMED_OUT
What am I missing?
Port 80 was blocked by Network security Group.
How to allow it: https://blogs.msdn.microsoft.com/pkirchner/2016/02/02/allow-incoming-web-traffic-to-web-server-in-azure-vm/

Unable to Connect Jenkins Windows 10 Slave to Master running

My environment:
Master:
Azure VM running Ubuntu 14.10
Docker (1.9) running Jenkins Image
I have added port 8080 (for UI) and 50000 (for slave) as endpoints on the Azure VM.
Slave:
Windows 10 (running on Mac via BootCamp)
Configured the firewall to allow inbound and outbound traffic on port 50000 (that slave jnlp seems to be using).
I can access my Jenkins Master install over the web. I am trying to configure the slave on my Windows 10 m/c. I have tried all 3 methods to configure the slave.
Each time after several retries, the slave throws the "Connection Refused" error (screenshot attached).
Slave Error Screenshot
Can someone help point me in the right direction? I have little knowledge of Linux systems but proficient with Windows.
I have tried the workaround here but it hasn't worked for me.
There's three things that I think you can check here:
Check that you expose port 50000 on your Jenkins docker container. Check for the Dockerfile, there must be a clause EXPOSE 5000 or something. Or when you run your container run it with something like this: docker run -it -p 50000:50000 which maps local post 50000 to the containers port 50000.
Check that you don't have any security rules on Azure blocking port 50000 to your Azure VM. Don't know about Azure but in AWS you allow port 50000 in your security group(s).
Check your Azure VM's firewall. Is it Windows? Check the firewall and allow port 50000. Is it Linux ? Check iptables and allow port 50000.
Hope it helps.

Resources