Tomcat not running on docker image - tomcat7

I installed tomcat7 on the image using Dockerfile through the command :
MAINTAINER Abc Xyz <abc#xyz.com>
RUN apt-get -qq update
RUN apt-get -y install openjdk-7-jre
RUN apt-get -y install tomcat7
EXPOSE 8080
When I build the image and try to run the following command :
sudo docker run -d -P abcxyz/tomcat service tomcat7 start
I don't get to see the tomcat page on the port to which it is mapped (say 49153)...
And when I run as a bash in the image and I try :
service tomcat7 start
Then also it fails to start the tomcat7 server.
I think that the problem is that image is unable to start the tomcat7 server. And I heard that docker images can't run any upstart services though I am not sure.
Anybody has any idea how to solve it?
Thanks.

change the command to
<path/to/tomcat>/bin/cataline.sh run
and this will make tomcat run in the forground

Just add:
--privileged=true
parameter with docker run command. Tomcat need extended privileges to run.
More informations there: https://docs.docker.com/reference/run/#runtime-privilege-linux-capabilities-and-lxc-configuration

It's not working, because the container will work for as long as the program you specified is running. The service tomcat7 start command finishes immediately.

You should run it like so:
docker run -dP abcxyz/tomcat catalina.sh run
This will make the container run as long as the command is executing. The way you were running it though is having the service as a background process.

use docker run with -d switch to run in detach mode. So it will run in background.
eg:
docker run -d abcd /path/catalina.sh run

Related

Is the docker daemon running? Spring-boot java project on Ubuntu

I have Ubuntu 22.04,
I have Java Spring-boot project, I run Idea, then run docker-compose.yml and get this message:
Cannot connect to the docker daemon at unix:///var/run/docker.sock.
Is the docker daemon running? (Details:[13] Permission denied)
What should I check?
You can take this perfect Tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-22-04
The important section for you is: Step 2 — Executing the Docker Command Without Sudo (Optional)
Your Problem is that you try to use docker without sudo. You have no permission for that.

RabbitMQ Docker Bash Script Issue - .sh Not Found

I am trying to create a RabbitMQ image that installs the rabbitmq_auth_backend_http plugin, and also executes a java application (.jar) via a bash script file. However, when I run the container I get this output from RabbitMQ:
/usr/local/bin/docker-deploy.sh: 2: /usr/local/bin/docker-deploy.sh:
: not found
Starting rabbit-sidecar application
Enabling plugins on node rabbit#039e6bd1bbfd:
bbitmq_auth_backend_http
The following plugins have been configured:
rabbitmq_auth_backend_http
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to rabbit#039e6bd1bbfd...
The following plugins have been enabled:
rabbitmq_auth_backend_http
set 4 plugins.
Offline change; changes will take effect at broker restart.
/usr/local/bin/docker-deploy.sh: 4: /usr/local/bin/docker-deploy.sh: rabbitmq-server
: not found
It's also not finding rabbitmq-server which is needed to restart rabbit for the plugin to work.
To note, the java application appears to be working as it should and is just logging what it normally logs when its spun up as its own container.
Dockerfile
FROM rabbitmq:3.8.2-management
COPY ./rabbitmq.conf /etc/rabbitmq/rabbitmq.conf
RUN apt -y update && apt -y install openjdk-8-jdk
RUN mkdir /sidecar
ADD ./target/demo-0.0.1-SNAPSHOT.jar /sidecar/demo-0.0.1-SNAPSHOT.jar
ADD ./docker-deploy.sh /usr/local/bin/docker-deploy.sh
RUN chmod 755 /usr/local/bin/docker-deploy.sh #755
ENTRYPOINT ["sh", "/usr/local/bin/docker-deploy.sh"]
Script
#!/bin/bash
echo "Starting rabbit-sidecar application"
rabbitmq-plugins enable rabbitmq_auth_backend_http; rabbitmq-server
# starts the sidecar
java -jar /sidecar/demo-0.0.1-SNAPSHOT.jar
My original custom image that worked was this:
FROM rabbitmq:3.8.2-management
COPY rabbitmq.conf /etc/rabbitmq/rabbitmq.conf
CMD ["sh", "-c", "rabbitmq-plugins enable rabbitmq_auth_backend_http; rabbitmq-server"]
Which worked fine, but obviously I needed to do what I am doing because I want to be able to run another service within the same container as it requires it.
I did notice that there is a docker-entrypoint.sh in /usr/local/bin. Is this something to be considered in this context?

How do I run the Hetionet v1.0 docker container?

I'm trying to run the Hetionet v1.0 docker container mentioned in this SO post.
I've setup a digitalocean droplet with Docker
I ran docker pull dhimmel/hetionet and it worked
Now I run docker run dhimmel/hetionet and the following happens (and never returns to the interactive shell prompt).
If that completed successfully I think the last thing I'm supposed to do is run sh ~/run-docker.sh. Furthermore nothing is live at my droplet's ip_address:7474.
The error in the screenshot above looks a lot like it could be related to some redundant #Path("/") annotation, as described in this SO post's comment, buried in the docker container but I'm not sure.
Is the output from running docker run dhimmel/hetionet supposed to hang my shell? I'm running a 2 GB Memory / 40 GB Disk Droplet on Ubuntu 16.04 with Docker 1.12.5.
Thanks for your interest in the Hetionet Docker.
The output in 3 is expected. It looks like a Docker container successfully launched, downloaded the Hetionet database, and launched the Neo4j server. I'll look into fixing the warnings, but they're not errors, as Neo4j is still launching.
For production, we use a more advanced Docker run command. Depending on your use case, you may want to use the development docker run command:
docker run \
--publish=7474:7474 \
--publish=7687:7687 \
--volume=$HOME/neo4j/hetionet-data:/data \
--volume=$HOME/neo4j/hetionet-logs:/var/lib/neo4j/logs \
dhimmel/hetionet
Both the production and development command map ports. This will make it so the Neo4j server running inside your Docker container is available at http://localhost:7474/. This is most likely what you want. If you're doing this on DigitalOcean, you would replace http://localhost with the IP address of your droplet.
For an interactive shell session in a dhimmel/hetionet container, you can use:
docker run --interactive --tty dhimmel/hetionet bash
However, that command does not launch the Neo4j server -- it just let's you explore the image.
Does this clear things up?

fork/exec ./debug: operation not permitted

My goal is to be able to remote debug from Atom.io. into a docker container running go in dlv debugger. This is the first problem:
Update:1. I am running Docker container on a mac, but that should not influence the code signing thing as I am running in a container, right?
Update:2. Codesignig the host, did not help.
Error:
1. root#...:/go/src/app# go get github.com/derekparker/delve/cmd/dlv
2. root#...:/go/src/app# dlv debug hello.go
could not launch process: fork/exec ./debug: operation not permitted
Then tried to
1. root#...:/go/src/app# sudo
2. bash: sudo: command not found
According Delve Issue #515
Docker has security settings preventing ptrace(2) operations by
default with in the container. Pass --security-opt seccomp:unconfined
to docker run when starting.
*confirmation of this in official docker bug tracker https://github.com/docker/docker/issues/21051
It seems to work if you start the container with --privileged. I've tried to figure out if there is a more fine-grained capability but failed.
Also I just found https://github.com/steeve/homebrew-delve which should make things easier on OSX.
Docker has security settings preventing ptrace(2)
See how i fixed it.
if using a docker-compose file to run the container then append seccomp:unconfined in the services section like below
api:
security_opt:
- seccomp:unconfined
if using docker run ...passing seccomp:unconfined works as well
Run Docker container as a command:
docker run -itd -p 2028:22 -p 2345:2345 --dns=10.236.8.8 --privileged=true --name=golang centos7-golang /usr/bin/supervisord
it works for me~

Unable to run Tomcat 7 as service inside container on CoreOS

I am trying to setup tomcat 7 on Digital Ocean CoreOS machine but facing some problem, not sure how to solve them. I am following below tutorial provided by the Digital Ocean to setup Apache.
https://www.digitalocean.com/community/tutorials/how-to-create-and-run-a-service-on-a-coreos-cluster
I created docker container and run it using following command.
docker run -i -t ubuntu:14.04 /bin/bash
I was successfully able to install tomcat 7 by using below commands. (I followed this tutorial to setup tomcat 7 within the docker container: https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-7-on-ubuntu-14-04-via-apt-get)
sudo apt-get update
sudo apt-get install tomcat7
Then I can created service unit file named as tomcat#.service
[Unit]
Description=Tomcat 7 web server service
After=etcd.service After=docker.service
Requires=tomcat-discovery#%i.service
[Service]
TimeoutStartSec=0 KillMode=none
EnvironmentFile=/etc/environment
ExecStartPre=-/usr/bin/docker kill tomcat%i
ExecStartPre=-/usr/bin/docker rm tomcat%i
ExecStartPre=/usr/bin/docker pull attacomsian/tomcat
ExecStart=/usr/bin/docker run –name tomcat%i -p ${COREOS_PUBLIC_IPV4}:%i:8080 attacomsian/tomcat `service tomcat7 start` -D FOREGROUND
ExecStop=/usr/bin/docker stop tomcat%i
[X-Fleet]
X-Conflicts=tomcat#*.service
Then I created tomcat-discovery#.service to register service states with Etcd as below
[Unit]
Description=Announce Tomcat#%i service
BindsTo=tomcat#%i.service
[Service]
EnvironmentFile=/etc/environment
ExecStart=/bin/sh -c “while true; do etcdctl set /announce/services/tomcat%i ${COREOS_PUBLIC_IPV4}:%i –ttl 60; sleep 45; done”
ExecStop=/usr/bin/etcdctl rm /announce/services/tomcat%i
[X-Fleet]
X-ConditionMachineOf=tomcat#%i.service
I submitted and loaded files to Fleet as below
fleetctl submit tomcat#.service tomcat-discovery#.service
fleetctl load tomcat#8080.service
fleetctl load tomcat-discovery#8080.service
Everything worked fine so far. I did not see any error. But when I tried to run the service as below
fleetctl start tomcat#8080.service
But it did not started. I can see it is appearing as dead.
I am new to CoreOS and still learning. I am managing servers at Digital Ocean and I quite about it quite well. I googled about this issue but did not found any help. I personally think following line is actually causing the trouble.
ExecStart=/usr/bin/docker run –name tomcat%i -p ${COREOS_PUBLIC_IPV4}:%i:8080 attacomsian/tomcat `service tomcat7 start` -D FOREGROUND
I would really appreciate any kind help to get this up.
Many Thanks
Attacomsian
I was going so suggest you take a look at what others have done and then discovered you have posted a similar question on the Docker Hub registry.
Did you take a look at the Docker file used by the tutum/tomcat image?
https://github.com/tutumcloud/tutum-docker-tomcat/blob/master/7.0/Dockerfile
https://github.com/tutumcloud/tutum-docker-tomcat/blob/master/7.0/run.sh
It runs a script called "run.sh" that runs tomcat in the foreground.
The thing that is tricky to understand is that Docker is not a virtual machine and therefore does not have any services running. You must run the docker processes explicitly or setup a process manager like runit or supervisord.
Hope this helps.

Resources