I am new to docker and I have tried following some tutorials and documentation on USING DOCKER TO EFFICIENTLY CREATE MULTIPLE TOMCAT INSTANCES, but am having trouble getting the service to run via the docker run command.
I have a docker file with the following coding below
FROM ubuntu:precise
MAINTAINER Quinten Krijger < qkrijger [at] gmail {dot} com>
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update && apt-get -y install python-software-properties
RUN add-apt-repository ppa:webupd8team/java
RUN apt-get update && apt-get -y upgrade
RUN echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
RUN apt-get -y install oracle-java7-installer && apt-get clean
RUN update-alternatives --display java
RUN echo "JAVA_HOME=/usr/lib/jvm/java-7-oracle" >> /etc/environment
When I build using the command
docker build -t quintenk/jdk7-oracle .
it shows the build is successful.
In the another dockerfile, I try to create create other images based on it
I have another docker in a different path with the following commands
FROM quintenk/jdk7-oracle
MAINTAINER Quinten Krijger "qkrijger#gmail.com"
RUN apt-get -y install tomcat7
RUN echo "JAVA_HOME=/usr/lib/jvm/java-7-oracle" >> /etc/default/tomcat7
EXPOSE 8080
CMD service tomcat7 start && tail -f /var/lib/tomcat7/logs/catalina.out
I use the following command to run the docker file
docker run -d quintenk/tomcat7
But it shows as tomcat instance fail
* Starting Tomcat servlet engine tomcat7
...fail!
If I give the command
docker ps
also there is no instance running on my machine
I'm obviously doing something wrong and I'm getting the behaviour on my OSX
For testing you can create a Dockerfile with CMD ["bash"].
start the container then login to the container using the command
docker -it exec container_name bash
then start tomcat and checkout out the tomcat logs
Try running the image with following command
docker run -dt --cap-add SYS_PTRACE quintenk/tomcat7
I have faced this issue. Finally, I am able to run the tomcat.Follow below steps.
Step-1: open terminal Ctrl+Alt+t
Step-2: then on terminal go inside the running container, type commands
sudo docker exec -it containerID /bin/bash
Now to check tomcat is running or not, type your container IP address followed by colon(:) 8080 port on the browser. like 172.17.0.2:8080.
Hope it helps!!
Related
I am trying to create a Docker container for a micro-service in SpringBoot Java in Ubuntu 21.10, but when I try to build the container I get this error, maybe it is a common error, but so far I can't solve it, I have checked some posts on Internet but had no luck finding a similar solution. Please I would really appreciate the help! Thank you in advance
This is my Dockerfile:
FROM ubuntu
RUN yum install -y java
VOLUME /tmp
ADD target/microservice-0.0.1-SNAPSHOT.jar app.jar
RUN sh -c 'touch /app.jar'
ENTRYPOINT ["java", "-Djava.security.egd-file:/dev/./urandom","-jar","/app.jar"]
This is the error I get:
docker build -t spring_boot_docker .
Sending build context to Docker daemon 17.72MB
Step 1/6 : FROM ubuntu
---> 54c9d81cbb44
Step 2/6 : RUN yum install -y java
---> Running in a2793e79925b
/bin/sh: 1: yum: not found
The command '/bin/sh -c yum install -y java' returned a non-zero code: 127
In ubuntu you can try installing with apt-get:
RUN apt-get update && \
apt-get install -y openjdk-8-jdk
What I would like is to add Java (installation and JAVA_HOME) in an image.
I'm using this postgres dockerfile: https://github.com/docker-library/postgres/tree/master/9.6
Which I updated with the following :
RUN apt-get -y update
RUN apt-get -y install wget
RUN apt-get -y install sudo
RUN /bin/mkdir /usr/lib/jvm
RUN wget https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -O /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz
RUN sudo tar xfvz /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz --directory /usr/lib/jvm
RUN rm -f /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz
ENV JAVA_HOME /etc/alternatives/jre
Please note that I'm beginner so if something is obvious for you it may not be for me.
The issue is that, /usr/lib/jvm is not created thus java is not installed and also JAVA_HOME is empty when I run the image.
When I execute manually the instructions, it works, but I would like to make my dockerfile working.
I'm trying to run a simple Tomcat8 server on my Ubuntu 16.04 Docker image. But I can't see the Tomcat default page.
1) I ran this command to run the container docker run -it --entrypoint bash e36658dffbd8
2) I opened up localhost:8080/ after installing tomcat8 in my container but it doesn't work.
Here is my Dockerfile
FROM ubuntu:16.04
# OS: Ubuntu 16.04
# Tomcat Setup
ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
RUN apt-get update
RUN apt-get install -y tomcat8 openjdk-8-jre-headless exuberant-ctags git telnet subversion mercurial wget inotify-tools unzip sysstat vim procps virtualenv python3-pip
EXPOSE 7443
EXPOSE 8080
You need to tell docker to map the exposed port to a local port:
docker run -it -p 8080:8080 --entrypoint bash e36658dffbd8
Also, I don't see anything in your dockerfile that will actually install Tomcat, so that would be a different problem.
I am trying to create a Dockerfile/Image which has all softwares necessary to set up a Java environment.
As per work requirement, I have to use CentOS6 as my base image and Java6, Tomcat6, Apache2.2, Maven 3.2.5 and Eclipse.
Currently I have below as the Dockerfile:
#centos6
FROM centos:6
#Java
RUN yum -y install java-1.6.0-openjdk-devel.x86_64
VOLUME ["/var/www/thml", "/etc/httpd/conf", "/etc/httpd/conf.d", "/tmp/applications", "/usr/local/tomcat", "/usr/local/maven"]
EXPOSE 80 443
ENTRYPOINT [ "/usr/sbin/httpd","-k","start", "-D", "FOREGROUND" ]
# apache
RUN yum -y install httpd
RUN cp -fp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.ORG
RUN sed -i -e 's/\#ServerName www.example.com:80/ServerName example-web-server.example.com/g' /etc/httpd/conf/httpd.conf
I am not certain how to make sure that each RUN command is working correctly as in whether a Java6 environment is set correctly, then an Apache..etc.
Use
RUN echo $JAVA_HOME
And while building the image using
docker build -t $YOUR_IMAGE_NAME
You can see the echo output in the build stdout which is printed on the console.
Trying to create a Dockerfile that'll download and install Java 8 on Amazon Linux.
Currently, I have the following file. It's a Play 2.3.4 app:
FROM dockerfile/java
RUN \
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
add-apt-repository -y ppa:webupd8team/java && \
apt-get update && \
apt-get install -y oracle-java8-installer && \
rm -rf /var/lib/apt/lists/*
MAINTAINER BeanstalkTest
EXPOSE 80 443
ADD files /
WORKDIR /opt/docker
RUN ["chown", "-R", "daemon", "."]
USER daemon
RUN ["bin/playapp", "-Dconfig.file=conf/prod.conf"]
The app takes a long time to deploy then fails. Any ideas what I could be doing wrong?
For me it looks like problem with connection.
Are you sure that this code works without Docker inside target host?
Does it work in your machine?
Are you sure that echo command is doing what you really want ? I mean installing java 8.
Ok so I will post my ideas:
Set up proxies: HTTP_PROXY, http_proxy, HTTPS_PROXY, https_proxy, http-proxy, https-proxy - yes that many proxies because different packages use different names of proxy.
Add proxy to etc/apt/apt.conf to Acquire::http::Proxy "http://proxy-abc.com:888/";
Add proxy to docker:
Inside etc/default/docker:
export http_proxy=http://proxy-abc.com:888/
export https_proxy=https://proxy-abc.com:888/
DOCKER_OPTS="-H tcp://127.0.0.1:4243 -H unix://var/run/docker.sock -g /docker"
Look at docker container logs: sudo cat log/var/lib/docker/containers/12eaca16d3cdc628304263b21d27614e5a0c44f09c2072470b09a1bb3def5559/12eaca16d3cdc628304263b21d27614e5a0c44f09c2072470b09a1bb3def5559-json.log
Does your target host has newest kernel ? In older kernels docker had problems with network communication
Does your target host had newest docker installed?
EDIT
Why wouldn't use prebuild images? FROM dockerfile/java:oracle-java8