How do I get an instance of docker-client from Mac? - docker

I've a docker running in my Mac which was installed through Home brew. I'm trying to invoke docker remote api through docker-client library. My docker daemon is running fine and exposed at tcp://192.168.99.100:2376. When I try to get instance from docker-client library using http://192.168.99.100:2376 I'm getting invalid scheme exception. How do I map tcp to http ports?

Please have a look at below points.
"192.168.99.100" is this your mac machine iP address? have you tried by using localhost:2376?
Can you please share the result of docker ps -a command? this command should show you which port you are exposing.
Can you please share your docker file?

Related

How to debug network host access

I'm having problems with getting proxy setup right in a docker container. I want to download a file from github, but get unable to resolve host address error from wget. Now, how do I debug what goes wrong in accessing the host? I want to see steps like :
requesting `docker.host.internal:3128" (my local proxy)
requesting "company.com/proxy:1234"
requesting "github.com".
What command line utility can get this information? or what other approach can I use to debug inaccessible host?
I had similar issues and found it helpful to debug by comparing behavior of curl locally and via docker.
curl google.com
docker run -it curlimages/curl google.com
If docker network setup is fine, result should be the same.
"unable to resolve host address" points to a problem with DNS resolution. You can try to ping the IP address of github. If you use docker behind a proxy, you need to make some configuration (https://docs.docker.com/network/proxy/). To test connectivity you can use: ping, curl, wget.

Resource cannot be found error when accessing a page in Docker Container

I created a asp.net webform project in Visual Studio with Docker support (Windows). When I run the project using Visual Studio page comes up as below
Visual Studio creates a docker image which I saw using command
docker images
See image below (webapplication3)
Now I run another instance of Image (webapplication3) by command
Docker run webapplication3:dev
I can see container running
Docker ps
see image below
But now when I access this new running container using ip http://172.17.183.118/PageA.aspx
it's not coming up, see image below (I have taken IP 172.17.183.118 from docker inspect command, so it is correct.
Can someone tell me why am I not able to view the page? Why is it saying "Resource cannot be found" error?
When you run a Docker container default, the container will run with an internal IP address and an expose port map the local machine port, and the IP address will go out to the internet through the docker bridge which associated with the local machine network interface.
When you access the container inside the local machine, you just need to access the localhost with the port shows you. In your issue, you need to access the address http://localhost:62774/PageA.aspx. If you want to access the container from the Internet, you should access the IP address of your local machine with the port. For you, it means the address http://your-local-machine-public-ip:62774/PageA.aspx.
You can get more details from Docker Network. Also, I suggest you'd better run the container with the special port you plan just like docker run -d -p nodePort:containerPort --name containerName yourImage.

how to get started with docker version of hortonworks after install

I followed the Docker installation (using the bash script) to install Hortonworks Sandbox onto a server via the Docker component. It is installed on ubuntu 18.04 server.
The install apparently worked. Now what I want to do is be able to get to the website from other machines in the network.
My IP range is standard 192.168.1.*, however, the sandbox container IP is 172.18.0.2. I want to reach the container from outside the server it's installed on. I'm told NAT will work, but I don't know how to work this.
How do I tell Docker/Ubuntu to forward requests to the sandbox? Or change the sandbox IP to something recognizable by other machines on the network?
Use docker run --network=host and all your ports will be listening via your host ip.

Access docker remote API from container

I'm trying to access Docker remote API from within a container because I need to start other containers.
The host address is 172.19.0.1, so I'm using http://172.19.0.1:2375/images/json to get the list of images (from host, http://localhost:2375/images/json works as expected.
The connection is refused, I guess because Docker (for Windows) listens on 127.0.0.1 and not on 0.0.0.0.
I've tried to change configuration (both from UI and daemon.json) adding the entry:
"hosts": ["tcp://0.0.0.0:2375"]
but the daemon fails to start. How can I access the api?
You can set DOCKER_OPTS in windows as below and try. In Windows, Docker runs inside a VM. So, you have to ssh into the VM and make the changes.
DOCKER_OPTS='-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock'
Check if it works for you.
Update :- To ssh into the VM (assuming default is the VM name you have created using Docker toolbox), enter the following command in the Docker Quickstart Terminal,
docker-machine ssh default
You can find more details here.
You could link the host's /var/run/docker.sock within the container where you need it. This way, you don't expose the Docker Remote API via an open port.
Be aware that it does provide root-like access to docker.
-v /var/run/docker.sock:/var/run/docker.sock
You should use "tcp://host.docker.internal:2375" to connect to host machine from container. Please make sure that you can ping the "host.docker.internal" address
https://github.com/docker/for-win/issues/1976

Port binding is not working in docker on windows

I have installed docker on my Windows m/c.
I am trying to install Gerrit on that.
Pull image is done-Successfully
Run image is also done -->
docker run -d -p 8080:8080 -p 29418:29418 ******/gerrit
I try to connect it through browser with my container id:8080 but it throws error
This site can’t be reached
What is oing wrong.. Please help with suggestions.
BR,
Rash
You need to access your container by IP of virtual machine. You can obtain it with command: docker-machine ls. Then access container in browser by (replace ip) http://192.168.99.100:8080
This is a known limitation of windows containers at the moment as per the docker documentation (https://docs.docker.com/docker-for-windows/troubleshoot/#limitations-of-windows-containers-for-localhost-and-published-ports).
As of Windows 10 Creator's update this has kinda been fixed where you can use host IP with the bounded host port(http://<hostIp>:<hostBoundedPort>), but still not localhost or any of it's aliases.
Alternatively you can avoid port mapping hit the container IP directly. There is numerous ways to get your container IP. Personally I would use:
docker ps
This lists out all the the running docker containers allowing you to find the Container ID for the container that you want to hit followed by:
docker inspect <initial_part_or_full_id>
This will output low level information about the container, including it's Network settings where you will find the NAT-ed endpoint details containing the IP. Then simply http://<containerIP>:<containerPort>.

Resources