Switching from Docker Desktop to Colima - no localhost access - docker

Trying to switch to colima from Docker Desktop on mac but having issues reaching my containers on localhost.
Removed Docker Desktop and installed colimna/docker w homebrew. Colima starts fine.
I have a command that I use to run Dynamo:
docker run --name dynamodb -d -p 8000:8000 amazon/dynamodb-local"
When I was using Docker Desktop I could reach the database on localhost:8000. Now it's only accessible on 127.0.0.1:8000
My /etc/hosts correctly maps localhost - this is an issue with the switch. Not finding much online regarding this - any ideas? It seems that docker no longer recognizes localhost as an alias for 127.0.0.1 after the switch. Not using Kubernetes or docker compose.

Related

Port doesn't open on Linux server when spinning up a docker container

I am trying to spin up a docker container on an Ubuntu server using the following command:
docker run -p 5432:5432 -e POSTGRES_USER=username -e POSTGRES_PASSWORD=password -e POSTGRES_DB=falafel postgres
and the port 5432 doesn't get opened on localhost. When I run the same command on my local machine (Macbook M1) the port gets opened as expected. This is the output of docker ps and nmap:
I don't have root permissions but I am in the docker group. I can open ports when not dealing with dockerized applications just fine. I tried restarting the docker daemon.
Anyone knows what might be the issue?
The issue was a collision of 2 docker services: docker-netns.service and docker.service. This made it look like the docker is correctly running but since I was not supposed to user the docker.service the port got exposed in global network and not in "my" network. After stopping and disabling docker.service and restarting docker-netns.service everything works as expected.

Unable to connect localhost using HyperV Container on Win10 1903

I was just upgraded to Windows 10 1903 from 1809, then my docker become a little bit weird. Here are my current situation:
OS: Microsoft Windows [ver 10.0.18362.116]
Hyper-V: Installed. I have only one VSwitch called Default Switch.
I reinstalled Docker Desktop for Windows v2.0.0.3. (Docker version 18.09.2, build 6247962)
The docker can run without problem. Only the network issue!
Here is what I tried:
Run iis container in "process" isolation mode.
docker run -d --rm -p 80:80 --isolation process mcr.microsoft.com/windows/servercore/iis:windowsservercore-1903
I can connect to port 80 through localhost.
Run iis container in "hyperv" isolation mode.
docker run -d --rm -p 80:80 --isolation hyperv mcr.microsoft.com/windows/servercore/iis:windowsservercore-1903
I can't connect to port 80 through localhost. I was okay before I upgrade to Windows 10 1903.
I almost tried everything I can try. I just can't get my localhost (loopback interface) works.
I tried on the other machine. When docker started, there is a nat VSwitch will be created by docker. It doesn't work on my machine.
I tried to create a new VMSwitch and named nat but doesn't works.
I tried to run .\WindowsContainerNetworking-LoggingAndCleanupAide.ps1 -Cleanup -ForceDeleteAllSwitches using this script. Restart the computer. It doesn't works.
I completely removed Hyper-V and Docker. Reinstall again doesn't works.
I tried to list networks defined in hnsdiag. (hnsdiag list networks) Then deleted the nat network. Restart the HNS service. Restart Docker again. It doesn't work.
May I ask what else I can do for my docker network settings?

How do I configure docker to allow a connection to a container from other computers?

I am trying to run a small test server with MS SQL Server running on a Mac in a Linux docker container. Maybe I have the terminology wrong so please correct me if necessary:
host - the macOS desktop with docker installed (ip 10.0.1.73)
container - the Linux instance running in the docker container with SQL Server running in it
remote desktop - another computer on the local area network trying to connect to SQL Server
I followed the MS installation instructions and everything seems to be running fine, except I can't connect to SQL Server from the Remote Desktop
I can connect to the docker host(10.0.1.73) and can ping the IP address
I can connect to SQL Server from the docker host and see the databases etc.
I used the following command to create the docker container
sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<XXXXXX>" -p 1433:1433 --name sqlserver1 -d microsoft/mssql-server-linux:2017-latest
Thinking that the -p 1433:1433 would map the linux port to the macOS host port and allow the remote computer to access the docker container when connecting to that port on the macOS host from the local area network
This is not working and I assume this may be to do with the network routing on the macOS host
Most solutions I have seen seem to indicate that one should use the VirtualBox UI to modify the network settings - but I don't have that installed
The others seem to have pages and pages of command line instructions that are required
Is there an easy solution somewhere I have missed?
EDIT:
Some more research and I found this explanation about how by default the Docker networking is set up for single host networking. Good explanation for anyone else struggling with the Docker concepts.
It is also worth reading up about the differences between docker containers and virtual machines...
https://youtu.be/Js_140tDlVI
Still trying to find some explanation on multi host networking.
try disabeling the firewall on the host you want to connect to.
port 1433 will be forwarded to the docker container, but your host (MAC) should have port 1433 open to be able to connect to your host.
Using NAT:
Assign the target address to your host interface:
sudo ifconfig en1 alias 10.0.1.74/21 up
Create the docker container and map the port to the second IP address assigned to the host interface
sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<XXXXXXXXX>" -p 10.0.1.74:1433:1433 --name sqlserver1 -d microsoft/mssql-server-linux:2017-latest

Accessing localhost of a docker container from the host

I am running the cloudera docker quickstart image (on windows) as explained on the this page.
I run it using:
docker run --hostname=quickstart.cloudera --privileged=true -t -i -p 7180:7180 -p 9080:9080 cloudera/quickstart:latest
It runs fine, I am able to run cloudera manager and access it using the url http://192.168.99.100:7180. So far so good. I also use tomcat with a simple app on localhost:9080 inside this same container. How do I access it on my host? I tried using http://192.168.99.100:9080 but it does not work.
Update: I fixed it by using the vm ip i.e. 192.168.99.100 instead of localhost for the server. Now it works. Thanks.

Docker container cannot connect to linked containers services

I'm using Docker version 1.9.1 build a34a1d5 on an Ubuntu 14.04 server host and I have 4 containers: redis (based on alpine linux 3.2), mongodb (based on alpine linux 3.2), postgres (based on ubuntu 14.04) and the one that will run the application that connects to these other containers (based on alpine linux 3.2). All of the db containers expose their corresponding ports in the Dockerfile.
I did the modifications on the database containers so their services don't bind to the localhost IP but to all addresses. This way I would be able to connect to all of them from the app container.
For the sake of testing, I first ran the database containers and then the app one with a command like the following:
docker run --rm --name app_container --link mongodb_container --link redis_container --link postgres_container -t localhost:5000/app_image
I enter the terminal of the app container and I verify that its /etc/hosts file contains the IP and names of the other containers. Then I am able to ping all the db containers. But I cannot connect to their ports to any of the db containers.
A simple: telnet mongodb_container 27017 simply sits and waits forever, and the same happens if I try to connect to the other db containers. If I run the application, it also complains that it cannot connect to the specified db services.
Important note: I am able to telnet the corresponding ports of all the db containers from the host.
What might be happening?
EDIT: I'll include the run commands for the db containers:
docker run --rm --name mongodb_container -t localhost:5000/mongodb_image
docker run --rm --name redis_container -t localhost:5000/redis_image
docker run --rm --name postgres_container -t localhost:5000/postgres_image
Well, the problem with telnet seems to be related to the telnet client on alpine linux since the following two commands showed me that the ports on the containers were open:
nmap -p27017 172.17.0.3
nc -vz 172.17.0.3 27017
Being focused mainly on the telnet command I issued, I believed that the problem was related to the ports being closed or something; and I overlooked the configuration file on the app that was being used to connect it to the services (it was the wrong filename), my bad.
All works fine now.

Resources