selenium - Exposing ports in Docker won't work -
i'm trying setup automated testing platform docker , selenium grid. in diagram below can see structure i'm using. on top ubuntu server running on compute engine. on left docker container running ubuntu 14.04. container runs our project on localhost:8080 google app engine. on right selenium hub 2 nodes running on port 4444.
this output when running docker ps:
container id image command created status ports names f5ac6e3c8270 xxxxx/ubuntuport:14.04 "/bin/bash" 3 days ago 13 seconds 0.0.0.0:32777->8080/tcp drunk_kalam 4246ca0790db eu.gcr.io/xxxxxx/selenium-chrome "/bin/sh -c 'rm -rf /" 4 weeks ago 3 days evil_mahavira 8d06f90a1a84 eu.gcr.io/xxxxxx/selenium-firefox "/bin/sh -c 'rm -rf /" 4 weeks ago 3 days nauseous_torvalds dc548f638778 eu.gcr.io/xxxxxx/selenium-hub "/opt/bin/entry_point" 4 weeks ago 3 days 0.0.0.0:32770->4444/tcp modest_khorana
as can see both hub , ubuntu container have ports activated, , forwarded ubuntu host running docker containers. i've opened these ports in google compute engine.
in docker container i'm running our project locally google app engine sdk. after using docker exec -it drunk_kalam bash
activate app engine server. command run within docker container. in future part of script, since still work in progress, being run within container. below can see project running:
root@f5ac6e3c8270:/# google_appengine/dev_appserver.py --php_executable_path=/usr/bin/php5-cgi --php_gae_extension_path=appengine-php-extension/modules/gae_runtime_module.so ./xxxxxxxxxxxxxxx/ info 2016-08-08 12:19:49,287 sdk_update_checker.py:229] checking updates sdk. warning 2016-08-08 12:19:49,532 simple_search_stub.py:1146] not read search indexes /tmp/appengine.xxxxxxxxxxx.root/search_indexes info 2016-08-08 12:19:49,535 api_server.py:205] starting api server at: http://localhost:39475 warning 2016-08-08 12:19:51,217 inotify_file_watcher.py:196] there many directories in application changes in of them monitored. may have restart development server see changes files. info 2016-08-08 12:19:51,218 dispatcher.py:197] starting module "default" running at: http://localhost:8080 info 2016-08-08 12:19:51,220 admin_server.py:116] starting admin server at: http://localhost:8000
the problem can't access project through port 8080. i've exposed port in dockerfile, , i've tried running container -p flag aswell -p 8080 flag. this:
docker run -dpi xxxxx/ubuntuport:14.04
i've started selenium hub same command, , port accessible. when running following command:
nmap -p 4444 172.17.0.3
i following output:
nmap scan report 172.17.0.3 host (0.00010s latency). port state service 4444/tcp open krb524 nmap done: 1 ip address (1 host up) scanned in 0.03 seconds
when run nmap on 8080 on docker container running project output:
nmap scan report 172.17.0.2 host (0.000085s latency). port state service 8080/tcp closed http-proxy nmap done: 1 ip address (1 host up) scanned in 0.03 seconds
i believe problem somewhere in dockerfile of ubuntu container. below can see dockerfile, dockerfile official ubuntu repository, added expose 8080
line.
from scratch add ubuntu-trusty-core-cloudimg-amd64-root.tar.gz / expose 8080 # few minor docker-specific tweaks # see https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap run set -xe \ \ && echo '#!/bin/sh' > /usr/sbin/policy-rc.d \ && echo 'exit 101' >> /usr/sbin/policy-rc.d \ && chmod +x /usr/sbin/policy-rc.d \ \ && dpkg-divert --local --rename --add /sbin/initctl \ && cp -a /usr/sbin/policy-rc.d /sbin/initctl \ && sed -i 's/^exit.*/exit 0/' /sbin/initctl \ \ && echo 'force-unsafe-io' > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup \ \ && echo 'dpkg::post-invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' > /etc/apt/apt.conf.d/docker-clean \ && echo 'apt::update::post-invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' >> /etc/apt/apt.conf.d/docker-clean \ && echo 'dir::cache::pkgcache ""; dir::cache::srcpkgcache "";' >> /etc/apt/apt.conf.d/docker-clean \ \ && echo 'acquire::languages "none";' > /etc/apt/apt.conf.d/docker-no-languages \ \ && echo 'acquire::gzipindexes "true"; acquire::compressiontypes::order:: "gz";' > /etc/apt/apt.conf.d/docker-gzip-indexes \ \ && echo 'apt::autoremove::suggestsimportant "false";' > /etc/apt/apt.conf.d/docker-autoremove-suggests run rm -rf /var/lib/apt/lists/* run sed -i 's/^#\s*\(deb.*universe\)$/\1/g' /etc/apt/sources.list cmd ["/bin/bash"]
the command used expose port same of selenium hub, different port number. can't seem figure out why port stays closed. appreciated.
thanks in advance
tijn
from output: 0.0.0.0:32777->8080/tcp
. says port 32777 listening on interfaces mapped (with nat , docker-proxy) port 8080 inside container. therefore you'd need access port 32777 instead of 8080. random port mapping happens when expose port , share -p
.
if want share specific port without random mapping, can define lower case p option: -p 8080:8080
or -p 8888:8080
map port 8888 port 8080 of container.
from chat session, turned out application listening on loopback inside container. netstat -lnt
, showed:
tcp 0 0 127.0.0.1:8080 0.0.0.0:* listen
updating application bind 0.0.0.0 allowed port forwarding work expected.
Comments
Post a Comment