docker - I have working with dockerfile to build and image and it build and run successfully but tomcat is not up -
i using dockerfile build image.
content of docker file:
from ubuntu # update ubuntu run apt-get update && apt-get -y upgrade # add oracle java 7 repository run apt-get -y install software-properties-common run add-apt-repository ppa:webupd8team/java run apt-get -y update # accept oracle java license run echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 boolean true" | debconf-set-selections # install oracle java run apt-get -y install oracle-java7-installer # install tomcat run apt-get -y install tomcat7 run echo "java_home=/usr/lib/jvm/java-7-oracle" >> /etc/default/tomcat7 expose 8080 # download slashdot homepage run mkdir /var/lib/tomcat7/webapps/slashdot run wget http://www.slashdot.org -p /var/lib/tomcat7/webapps/slashdot # start tomcat, after starting tomcat container stop. use 'trick' keep running. cmd service tomcat7 start && tail -f /var/lib/tomcat7/logs/catalina.out
when try build image using command docker build -t sample .
, image build successfully.
when try run command using
docker run -it --rm -p 8080:8080 sample
it shows: starting tomcat servlet engine tomcat7
but when try open localhost:8080
, shows webpage not available
.
please suggest why not working.
since in boot2docker environment, means port 8080 mapped 8080 in boot2docker vm (the linux host). not in pc (windows actual host).
you need open port in virtualbox in order said port visible windows host, , browser access localhost:8080.
see boot2docker: can't ports forwarding work more:
(make sure c:\path\to\virtualbox
in path
)
you can set permanent virtualbox nat port forwarding:
vboxmanage modifyvm "boot2docker-vm" --natpf1 "tcp-port8080,tcp,,8080,,8080";
if vm running, should run other command:
vboxmanage controlvm "boot2docker-vm" natpf1 "tcp-port8080,tcp,,8080,,8080";
Comments
Post a Comment