I have a windows container running the microsoft/iis base image, with Docker Desktop for Windows
I built the image using the following:
Command:
docker build -t test-iis-image .
File:
FROM microsoft/iis
EXPOSE 8080'
I then run a container using:
Command:
docker run -d -p 8080:8080 test-iis-image
I got the IP address of the container (e.g. 172.18.167.181)
added a route:
Command
route /P add 172.0.0.0 MASK 255.0.0.0 10.0.75.1
and then tried to connect to the container using the following url:
http://172.18.167.181:8080/
I am expecting to see the default IIS web page, but all I get is:
The following error was encountered while trying to retrieve the URL: > > > http://172.18.167.181:8080/
Connection to 172.18.167.181 failed.
The system returned: (110) Connection timed out
The remote host or network may be down. Please try the request again.
However, when i ping the ip address it seems to find the container:
ping 172.18.167.181
Pinging 172.18.167.181 with 32 bytes of data:
Reply from 172.18.167.181: bytes=32 time<1ms TTL=128
Reply from 172.18.167.181: bytes=32 time<1ms TTL=128
Reply from 172.18.167.181: bytes=32 time=1ms TTL=128
Reply from 172.18.167.181: bytes=32 time<1ms TTL=128
Ping statistics for 172.18.167.181:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
I think it not working because the default port inside the container is not 8080. It's 80. So change your
docker run -d -p 8080:8080 test-iis-image
to
docker run -d -p 8080:80 test-iis-image
For more details refer to https://hub.docker.com/r/microsoft/iis/
Also you can view one of the main Dockerfiles here
https://github.com/microsoft/iis-docker/blob/main/windowsservercore-ltsc2022/Dockerfile
Related
I have set up two new projects in Visual Studio using the Docker tooling. The first is a asp.net site running against a Linux container.
The second is an asp.net site running against a Windows container.
In the former, I can ping hostnames (ex: google.com) and it resolves just fine.
However, when running the windows container I cannot do the same thing.
I am running a custom network so that I can ensure the container starts up on the subnet I want:
docker network create --driver=nat --subnet=192.168.221.0/24
To be clear, I can ping just fine by using an IP but since I want to connect to a database via hostname, this isn't especially helpful during development.
I just figured this out. Requires "switching to windows container" in Docker Desktop.
1). Follow: https://docs.docker.com/machine/drivers/hyper-v/#example:
2). Start hyper v (may need to enable): https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v
3). Then in hyper v create external virtual switch. Select your wifi adapter. (should work with vpn on or off).
4). reboot.
5). I used this images as it has to match my local windows windows 10 version:1809
docker pull mcr.microsoft.com/windows:1809 #takes an hour to finish
6). Start container and attach to new network.
docker run -dit --name win1809 mcr.microsoft.com/windows:1809 powershell
docker network ls
docker network connect "John Windows Container Switch" win1809
docker network inspect "John Windows Container Switch"
shows:
"Containers": {
"b8c4ae07761fdf082602f836654013b8d83a717cce9156880a80c7542d855842": {
"Name": "win1809",
"EndpointID": "e84652fc93fd1fa2970c3bdcad513d8928fc35823a9f8cf0e638926b6091a60c",
"MacAddress": "00:15:5d:fb:77:dd",
"IPv4Address": "",
"IPv6Address": ""
7). Connect to container and ping something:
docker exec -it win1809 powershell
ping www.google.com
Pinging www.google.com [172.217.10.36] with 32 bytes of data:
Reply from 172.217.10.36: bytes=32 time=19ms TTL=118
Reply from 172.217.10.36: bytes=32 time=18ms TTL=118
Reply from 172.217.10.36: bytes=32 time=18ms TTL=118
Reply from 172.217.10.36: bytes=32 time=14ms TTL=118
I am a beginner to docker.Please correct me if anything wrong.
As shown in this docker swarm tutorial https://www.youtube.com/watch?v=nGSNULpHHZc , i am trying to setup multhost setup for my hyperledger fabric application.
I am using two oracle linux servers namely server 1 and server 2.
I connected both the servers using the docker swarm as managers and created overlay network called my-net.
I followed the same syntax given in the above mentioned tutorial and created the service using the beolw mentioned syntax.
docker service create --name myservice --network my-net --replicas 2 alpine sleep 1d
As expected it created one conatianer in each the server.
Say for example server 1 coantainer IP is 10.0.0.4 and server 2 container IP 10.0.0.5.
Now, i am trying to ping from the second servers container to first server's container as shown below and it is pinging.
# docker exec -it ContainerID sh
/ # ping 10.0.0.4
PING 10.0.0.4 (10.0.0.4): 56 data bytes
64 bytes from 10.0.0.4: seq=0 ttl=64 time=0.082 ms
64 bytes from 10.0.0.4: seq=1 ttl=64 time=0.062 ms
64 bytes from 10.0.0.4: seq=2 ttl=64 time=0.067 ms
^C
--- 10.0.0.4 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.062/0.070/0.082 ms
Now, I am trying to create my service(1) using the beolw mentioned syntax.
docker service create --name myservice1 --network my-net --replicas 2 hyperledger/fabric-peer sleep 1d
As expected this also created one conatianer in each the server.
Say for example server 1 coantainer IP is 10.0.0.6 and server 2 container IP 10.0.0.7.
Now, I am trying to ping from the second servers container to first server's container as shown below.
This time i am getting ping not found error,
# docker exec -it ContainerID sh
# ping 10.0.0.6
sh: 1: ping: not found
Can anyone please help what is the problem with the second myservice1.
The Fabric Docker images are based on a bare bones base Ubuntu image and do not include utilities like ping. Once you "exec" into the peer containers, you use "apt" to install ping:
apt-get update
apt-get install inetutils-ping
Added -ping at the end
Expanding on Gari Singh's answer, on a Fabric network I've spun this week, the inetutils has been split in different packages:
# apt-cache search inetutils
inetutils-ftp - File Transfer Protocol client
inetutils-ftpd - File Transfer Protocol server
inetutils-inetd - internet super server
inetutils-ping - ICMP echo tool
inetutils-syslogd - system logging daemon
inetutils-talk - talk to another user
inetutils-talkd - remote user communication server
inetutils-telnet - telnet client
inetutils-telnetd - telnet server
inetutils-tools - base networking utilities (experimental pac
so to install e.g. ping the correct command has become:
# apt-get install inetutils-ping
The Ubuntu version of the peer is:
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LTS"
I solved it, se the edit at the end of the description.
I'm using Centos7 as a host and running docker version 17.05.0-ce
I'm able to pull images on to the host.
from inside a contiainer I'm able to ping the docker interface, I'm also able to ping the host machine. But thats it, I'm not able to ping any other hosts, not the dns on the local network, not google, nothing. I guess it's something with the routing, but I can't figure it out.
Anyone got an idea?
This is (obviously) not about connecting to other containers on the same host. but probably a problem with the routing or configuration in docker
jonmat ~ $ docker -v
Docker version 17.05.0-ce, build 89658be
# pulling images works fine, so the engine can connect to the internet
jonmat ~ $ docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
ff3a5c916c92: Pull complete
Digest: sha256:7b848083f93822dd21b0a2f14a110bd99f6efb4b838d499df6d04a49d0debf8b
Status: Downloaded newer image for alpine:latest
# pinging google dns from the host is is no problem
jonmat ~ $ ping -c1 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=5.16 ms
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 5.160/5.160/5.160/0.000 ms
# pinging google dns from inside the container won't work, probably some kind of routing issue?
jonmat ~ $ docker run -it --rm alpine ping -c1 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 0 packets received, 100% packet loss
EDIT:
I found the problem myself. someone other than me have also been using the host, and they added the option "--ptables=false" to dockerd, i removed this and it solved my problem.
Assuming your container is running with name alpine, can you try below command
docker exec -t alpine ping 8.8.8.8
In the example given above, seems you are missing some options, try this
docker run -it --rm -t alpine ping -c1 8.8.8.8
If container is already running use docker exec like posted above. (I would like to combine both answers, but unfortunately I am not finding option to delete and add it in the first answer itself)
Refer the docker exec for more details
I am looking for a solution to ping a Docker container using its hostname, from another Docker Container.
I tried as follow:
starting first Docker container:
docker run --rm -ti --hostname=repohost --name=repo repo
starting second Docker container, link to first and start bash:
docker run --rm -ti --hostname=repo2host --link repo:rp repo2 /bin/bash
on bash started on repo2
ping repohost
it remain on pending without any result.
Can someone tell me if there is a solution for this?
You should be able to ping using the alias you gave in the link command (the part after the :), in your case ping rp should work.
The following works for me, given a running container called furious_turing:
$ docker run -it --link furious_turing:ft debian /bin/bash
root#06b18931d80b:/# ping ft
PING ft (172.17.0.3): 48 data bytes
56 bytes from 172.17.0.3: icmp_seq=0 ttl=64 time=0.136 ms
56 bytes from 172.17.0.3: icmp_seq=1 ttl=64 time=0.091 ms
56 bytes from 172.17.0.3: icmp_seq=2 ttl=64 time=0.092 ms
^C--- ft ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.091/0.106/0.136/0.000 ms
root#06b18931d80b:/#
If you need to ping on another name, you can add entries to /etc/hosts with the --add-host argument to docker run.
One way to achieve what you need would be with WeaveDNS.
I'm trying to configure fig so that I can connect to my database server without specifying a fully qualified domain name. The database is running on bare metal (not in docker). On the host, glinda.local is specified in /etc/hosts and I'd like the container to mimic this behavior (though not rely on the host's config).
I found this suggestion on github, but it fails since /etc/hosts is on a read-only file system.
So the question remains, how can I add glinda.local from fig.yml to /etc/hosts inside my docker container?
From Docker v1.3.1 (I think) you have available the option --add-host in docker run. Unfortunately this options has not been merged to fig:master yet, but there is a PR with it. When merged (or using that branch) you should be able to use it in this way:
extra_hosts
Add hostname mappings. Use the same values as the docker client
--add-hosts parameter.
> extra_hosts:
> - docker: 162.242.195.82
> - fig: 50.31.209.229
An entry with the ip address and hostname will be created in
/etc/hosts inside containers for this service, e.g:
> 162.242.195.82 docker
> 50.31.209.229 fig
What makes you think /etc/hosts is read-only? The following works for me with Docker 1.5:
$ docker run -it debian
root#0989fd55e8fa:/# echo "127.0.0.1 test" >> /etc/hosts
root#0989fd55e8fa:/# ping test
PING test (127.0.0.1): 48 data bytes
56 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.078 ms
56 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.068 ms
^C--- test ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.068/0.073/0.078/0.000 ms
Are you saying this doesn't work for you? If the above works, you should be able to add what you need into an entrypoint script.