Cannot start service www: driver failed programming external connectivity on endpoint - java

I converted this original project into a docker-compose project here and followed a their setup instructions. It seems that I am not able to connect with the browser.
The SQL file contains the database schema and looks like this:
CREATE DATABASE mgsv;
CREATE USER 'mgsv_user'#'localhost' IDENTIFIED BY 'mgsvpass';
GRANT SELECT, INSERT, CREATE, DROP ON mgsv.* TO 'mgsvuser'#'localhost';
use mgsv;
CREATE TABLE IF NOT EXISTS `userinfo` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`email` text NOT NULL,
`hash` text NOT NULL,
`synfilename` text NOT NULL,
`annfilename` text NOT NULL,
`url` text NOT NULL,
`session_id` text NOT NULL,
`annImage` int(5) NOT NULL,
`create_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
The docker-compose.yml looks like this:
version: '3.1'
services:
db:
image: mysql
restart: always
environment:
- MYSQL_DATABASE=mgsv
- MYSQL_USER=mgsv_user
- MYSQL_PASSWORD=mgsvpass
- MYSQL_ROOT_PASSWORD=mysql123
volumes:
- ./mysql:/docker-entrypoint-initdb.d
www:
build: ./mGSV
restart: always
ports:
- 8080:8080
And the Dockerfile contains PHP and all other tools setup and looks like this.
FROM php:5-apache
RUN apt-get update && apt-get install -y --no-install-recommends \
openjdk-7-jdk \
maven \
git \
&& rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/qunfengdong/mGSV.git
# Move the folder 'mgsv' to DocumentRoot of Apache web server. By default, the DocumentRoot of Apache is /var/www/ (speak to the system administrator to know the exact DocumentRoot).
RUN cd /var/www/html/mGSV \
&& mkdir tmp \
&& chmod -R 777 tmp
RUN cd /var/www/html/mGSV && sed -i.bak "s|'gsv'|'mgsv_user'|" lib/settings.php \
&& sed -i.bak "s|$database_pass = ''|$database_pass = 'mgsvpass'|" lib/settings.php \
&& sed -i.bak "s|cas-qshare.cas.unt.edu|localhost|" lib/settings.php
RUN cp /var/www/html/mGSV/Arial.ttf /usr/share/fonts/truetype/
#Do not understand
#7. Cleanup scripts are provided to drop database synteny and annotation tables, remove entries from database table 'userinfo' and delete the folder containing image files which are older than 60 days. This task is accomplished by cron job to run the cleanup script every day. To create a cron job, use the command below:
# shell> crontab -e
#At the last line of crontab, copy and paste the line below, and provide the exact path to mgsv/lib/cleanup.php
# 30 04 * * * /var/www/mgsv/lib/cleanup.php
#The script cleanup.php will be executed at 4:30 AM every morning.
#8. mGSV uses the mail function from PHP to send email to users. Speak to your system administrator to provide required information in the PHP configuration file called 'php.ini'.
#9. When installation completes, you can now open Install/index.php (i.e., http://<YOUR_SERVER_DOMAIN_NAME>/mgsv/Install/), which verifies prerequisites, database setup, and installation. YOUR_SERVER_DOMAIN_NAME refers to the domain name of your server.
RUN cd /var/www/html/mGSV/ws \
&& tar -xzf mgsv-ws-server.tar.gz
RUN cd /var/www/html/mGSV/ws/mgsv-ws-server \
&& mvn package
RUN cp -f /var/www/html/mGSV/ws/mgsv-ws-server/target/ws-server-1.0RC1-jar-with-dependencies.jar /var/www/html/mGSV/ws/
RUN cd /var/www/html/mGSV/ws \
&& echo "mgsv_upload_url=http://localhost/mgsv" > config.properties \
&& echo "ws_publish_url=http\://localhost\:8081/MGSVService" >> config.properties \
&& java -jar ws-server-1.0RC1-jar-with-dependencies.jar &
#To stop the web service
#shell> ps aux | grep ws-server-1.0RC1-jar-with-dependencies.jar
#*Note the process id from the output*
#shell> kill -9 <process id>
This is the output which I got:
Successfully tagged mgsvdocker_www:latest
Starting mgsvdocker_www_1 ...
mgsvdocker_db_1 is up-to-date
Starting mgsvdocker_www_1 ... error
ERROR: for mgsvdocker_www_1 Cannot start service www: driver failed programming external connectivity on endpoint mgsvdocker_www_1 (37d78703b379b65521d9fc15d2d1d51379f7eee71f7dc912585e088d8bf1b4e9): Bind for 0.0.0.0:8080 failed: port is already allocated
ERROR: for www Cannot start service www: driver failed programming external connectivity on endpoint mgsvdocker_www_1 (37d78703b379b65521d9fc15d2d1d51379f7eee71f7dc912585e088d8bf1b4e9): Bind for 0.0.0.0:8080 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.
I am not quite sure whether I did a mistake in the docker-compose.yml file or database configuration inside the Dockerfile.
By any chance, do anyone know what I am missing?
Thank you in advance

Related

unable to execute oracle data setup script from docker compose

I am trying to set up oracle data once my oracle container is up and running, below is my compose file:
version: '3'
services:
oracle:
image: absolutapps/oracle-12c-ee
container_name: oracle-docker
ports:
- 8080:8080
- 1521:1521
environment:
CASSANDRA_BROADCAST_ADDRESS: 127.0.0.1
ORACLE_ALLOW_REMOTE: "true"
volumes:
- ./scripts/oracle-init.sh:/oracle-init.sh
oracle-init.sh:
#!/usr/bin/env bash
echo "### SETUP EXECUTION! ###"
sqlplus -s "system/oracle#localhost:1521/orcl /scripts/init-oracle.sql"
echo "### SETUP EXECUTED! ###"
init-oracle.sql :
CREATE USER ot_consumer_tryout IDENTIFIED BY ot_consumer_tryout;
Can anyone help me what is wrong with above snippets. My docker container getting started but sql script does not execute ,here is the log from terminal:
oracle-docker | Running init scripts...
oracle-docker | Init scripts in /oracle.init.d/: Ignoring /oracle.init.d/*
oracle-docker |
oracle-docker | Done with scripts we are ready to go
Look at the volume you created
- ./scripts/oracle-init.sh:/oracle-init.sh
which means inside your container the file is in '/oracle-init.sh' but your
container might be expecting in a different location something with folder name oracle.init.d as per your container log.
oracle-init.sh is trying to run /scripts/init-oracle.sql , hope your image already has it otherwise you will have to mount it as well in compose file.

'no identity found' when using gradle to exec codesign

I am trying to sign my Java/JavaFX application using codesign with gradle. My gradle code is as following:
exec {
val codeSignArgs = listOf("-s", "'${macSigningKeyDeveloperIdApp}'", "--timestamp", "--options", "runtime", "--entitlements", "../../../entitlements.plist", "--deep", "-f", "--verbose", "UTMCoordinateConverter.app")
logger.quiet("code sign args: $codeSignArgs")
workingDir = macRel
isIgnoreExitValue = true
executable = codeSignTool.absolutePath
args(codeSignArgs)
}
Where codeSignTool is /usr/bin/codesign and macRel is the directory where the app file is, and macSigningKeyDeveloperIdApp is my signing developer id.
Gradle gives me the following output:
> Task :codeSign
Inside codeSign
code sign args: [-s, 'Developer ID Application: Victor Ewert (XXXXXXXXXX)', --timestamp, --options, runtime, --entitlements, ../../../entitlements.plist, --deep, -f, --verbose, UTMCoordinateConverter.app]
BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
'Developer ID Application: Victor Ewert (XXXXXXXXXX)': no identity found
2:38:26 p.m.: Task execution finished 'codeSign'.
The strange thing is, I can run the (equivalent) command fine, from the command line using:
/usr/bin/codesign -s 'Developer ID Application: Victor Ewert (XXXXXXXXX)' --timestamp --options runtime --entitlements ../../../entitlements.plist --deep -f --verbose UTMCoordinateConverter.app
run from the location of the app file.
I have double and triple checked my Developer ID, and it looks fine (checked using security find-identity -p codesigning -v login.keychain. I have also made sure my login keychain is unlocked. I don't think it is a problem with my Developer ID.
I'm guessing it has something to do with how gradle is executing the command, but I can't figure it out.

Accessing host postgresql from docker container (docker on linux)

I have a spring-boot java application running in a docker container on my linux host machine.
I have a postgresql instance installed on the host that I want to connect to from the running container.
I've tried multiple different approaches (--network="host" is not what I want).
My Dockerfile looks like this:
FROM openjdk:13-ea-9-jdk-alpine3.9
EXPOSE 8080
CMD mkdir /opt/StatisticalRestService
COPY target/StatisticalRestService-0.0.1-SNAPSHOT.jar
/opt/StatisticalRestService/
COPY DockerConfig/application.yml /opt/StatisticalRestService/
RUN chmod 777 /opt/StatisticalRestService/StatisticalRestService-0.0.1-SNAPSHOT.jar \
&& ls -l /opt/StatisticalRestService/StatisticalRestService-0.0.1-SNAPSHOT.jar \
&& INTERNAL_HOST_IP=$(ip route show default | awk '/default/ {print $3}') \
&& echo "$INTERNAL_HOST_IP host.docker.internal" >> /etc/hosts \
&& chmod +r /etc/hosts \
&& cat /etc/hosts
ENTRYPOINT [ "java", "-jar", "-Dspring.config.location=/opt/StatisticalRestService/application.yml", "/opt/StatisticalRestService/StatisticalRestService-0.0.1-SNAPSHOT.jar" ]
application.yml:
spring:
application:
name: StatisticalRestService
jpa:
database: POSTGRESQL
show-sql: true
hibernate:
ddl-auto: create-drop
datasource:
platform: postgres
#url: jdbc:postgresql://host.docker.internal:5432/StatisticalRestService
url: jdbc:postgresql://172.17.0.1:5432/StatisticalRestService
username: statEntityUser
password: test123
driverClassName: org.postgresql.Driver
I have configured postresql's setting listen_addressess = '*' and the following entry is in the pg_hba.conf:
host all all 172.17.0.0/16 md5
host all all 192.168.1.0/24 md5
ifconfig docker0:
arizon#tuxpad:~/Utveckling/StatisticalRestService$ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:3bff:fe4f:ed34 prefixlen 64 scopeid 0x20<link>
ether 02:42:3b:4f:ed:34 txqueuelen 0 (Ethernet)
RX packets 28 bytes 1506 (1.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 198 bytes 25515 (25.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
This is the build output:
arizon#tuxpad:~/Utveckling/StatisticalRestService$ sudo docker build . -t arizon/statisticalrestservice:1.0.0-SNAPSHOT
Sending build context to Docker daemon 223.7MB
Step 1/7 : FROM openjdk:13-ea-9-jdk-alpine3.9
---> 6a6c49978498
Step 2/7 : EXPOSE 8080
---> Running in df7ebc70e950
Removing intermediate container df7ebc70e950
---> 417e50a9f5fd
Step 3/7 : CMD mkdir /opt/StatisticalRestService
---> Running in f33ca0acddf7
Removing intermediate container f33ca0acddf7
---> 59ae394176f3
Step 4/7 : COPY target/StatisticalRestService-0.0.1-SNAPSHOT.jar /opt/StatisticalRestService/
---> 4fbcfeb039f8
Step 5/7 : COPY DockerConfig/application.yml /opt/StatisticalRestService/
---> 244d31fc4755
Step 6/7 : RUN chmod 777 /opt/StatisticalRestService/StatisticalRestService-0.0.1-SNAPSHOT.jar && ls -l /opt/StatisticalRestService/StatisticalRestService-0.0.1-SNAPSHOT.jar && INTERNAL_HOST_IP=$(ip route show default | awk '/default/ {print $3}') && echo "$INTERNAL_HOST_IP host.docker.internal" >> /etc/hosts && chmod +r /etc/hosts && cat /etc/hosts
---> Running in 241f43aebbdc
-rwxrwxrwx 1 root root 35266534 Mar 16 19:52 /opt/StatisticalRestService/StatisticalRestService-0.0.1-SNAPSHOT.jar
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2 241f43aebbdc
172.17.0.1 host.docker.internal
Removing intermediate container 241f43aebbdc
---> 5c6c53d8011d
Step 7/7 : ENTRYPOINT [ "java", "-jar", "-Dspring.config.location=/opt/StatisticalRestService/application.yml", "/opt/StatisticalRestService/StatisticalRestService-0.0.1-SNAPSHOT.jar" ]
---> Running in 213a87164e8f
Removing intermediate container 213a87164e8f
---> 802cd987771f
Successfully built 802cd987771f
Successfully tagged arizon/statisticalrestservice:1.0.0-SNAPSHOT
When I run this with the datasource url pointed to host.docker.internal, i get unknownHostException, despite the output from the /etc/hosts file confirming it's there. From what I understand, there might be an issue with /etc/nsswitch.conf under alpine. I've tried adding the file and pasting this line from my host:
hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname
to no avail.
When I run it with the datasource url pointed to 172.17.0.1:5432, I get connection timed out.
I verified access to psql from my host by pointing pgadmin to the 192.168 ip to verify that listen_addresses = '*' works:
host all all 192.168.1.0/24 md5
which it does. It's a different entry tho.
Docker version:
Client:
Version: 18.09.2
API version: 1.39
Go version: go1.10.4
Git commit: 6247962
Built: Tue Feb 26 23:52:23 2019
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.09.2
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 6247962
Built: Wed Feb 13 00:24:14 2019
OS/Arch: linux/amd64
Experimental: false
Postgresql version:
arizon#tuxpad:~/Utveckling/StatisticalRestService$ dpkg --list | grep postgresql
ii postgresql-10 10.6-0ubuntu0.18.04.1 amd64 object-relational SQL database, version 10 server
So, TL;DR: Two questions:
1. How do I get host.docker.internal to work on docker under linux?
2. How do I connect my containerized application to my host postgresql instance?
I solved this not in the way I intended when I asked the question but It's solved.
I ended up creating a postgres container too with a volume to keep the persisted data persitent.
I made a Dockerfile for postgres that looks like this:
FROM postgres:10-alpine
RUN mkdir /docker-entrypoint-initdb.d/
#COPY initdb.sql /docker-entrypoint-initdb.d/
COPY my-postgres.conf /usr/local/share/postgresql/postgresql.conf
#ENV POSTGRES_USER statEntityUser
#ENV POSTGRES_PASSWORD test123
#ENV POSTGRES_DB StatisticalRestService
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 5432
CMD [ "postgres" ]
The initdb.sql script is just creating the same thing that the commented environment variables are, the user, password and database. Sql-scripts placed in that folder is run by the entry point script when the database is started and ready (it's an out-of-the-box feature in the docker image I derive from). The reason they are commented out is that it's in the docker-compose file (see below). The postgresql.conf is basically the template that is included in the container but with listen_addresses = '*' uncommented.
I also made a docker-compose.yml to run both of these containers in a good way together:
version: "3"
services:
statistical-rest-service:
build: ./StatisticalRestService
ports:
- 8081:8080
depends_on:
- postgres
networks:
- statisticsNet
postgres:
container_name: postgres
build: ./Postgres
ports:
- 5433:5432
volumes:
- postgres-volume:/var/lib/postgresql/data
command: postgres -c 'config_file=/usr/local/share/postgresql/postgresql.conf'
networks:
- statisticsNet
environment:
POSTGRES_USER: statEntityUser
POSTGRES_PASSWORD: test123
POSTGRES_DB: StatisticalRestService
networks:
statisticsNet:
volumes:
postgres-volume:
I'm not sure if you have to create the volume before hand or if it's included in docker-compose but if you need to, it's just docker volume create postgres-volume.
Postgres documentation on how to use the image and/or derive from it: Postgres on docker hub
NOTE: When you start the container with an appointed volume, make some mistake and shut it down, when you start it again, it will not mess with the existing database on the volume. You might get into a position where you have "dangling volumes" that are stale versions of old run-time containers that you've killed and removed but they can produce unexpected behavior (for me, the user and database wasn't created because of this).
You can clear them with this command: docker volume rm $(docker volume ls -qf dangling=true) (or run the command inside $() to list eventual dangling volumes.
Since I am creating a dedicated docker network in the docker-compose file, the containers can find each other by name (note container_name). That makes the connection url in the application.yml for my java like this: url: jdbc:postgresql://postgres:5432/StatisticalRestService
I hope someone is helped by this :)

How to add module to Wildfly using CLI

I'm trying to create a Wildfly docker image with a postgres datasource.
When I build the dockerfile it always fails with Permission Denied when I try to install the postgres module.
My dockerfile looks look this:
FROM wildflyext/wildfly-camel
RUN /opt/jboss/wildfly/bin/add-user.sh admin admin --silent
ADD postgresql-9.4-1201.jdbc41.jar /tmp/
ADD config.sh /tmp/
ADD batch.cli /tmp/
RUN /tmp/config.sh
Which calls the following:
#!/bin/bash
JBOSS_HOME=/opt/jboss/wildfly
JBOSS_CLI=$JBOSS_HOME/bin/jboss-cli.sh
JBOSS_MODE=${1:-"standalone"}
JBOSS_CONFIG=${2:-"$JBOSS_MODE.xml"}
function wait_for_wildfly() {
until `$JBOSS_CLI -c "ls /deployment" &> /dev/null`; do
sleep 10
done
}
echo "==> Starting WildFly..."
$JBOSS_HOME/bin/$JBOSS_MODE.sh -c $JBOSS_CONFIG > /dev/null &
echo "==> Waiting..."
wait_for_wildfly
echo "==> Executing..."
$JBOSS_CLI -c --file=`dirname "$0"`/batch.cli --connect
echo "==> Shutting down WildFly..."
if [ "$JBOSS_MODE" = "standalone" ]; then
$JBOSS_CLI -c ":shutdown"
else
$JBOSS_CLI -c "/host=*:shutdown"
fi
And
batch
module add --name=org.postgresql --resources=/tmp/postgresql-9.4-1201.jdbc41.jar --dependencies=javax.api,javax.transaction.api
/subsystem=datasources/jdbc-driver=postgresql:add(driver-name=postgresql,driver-module-name=org.postgresql,driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource)
run-batch
The output when building is:
==> Starting WildFly...
==> Waiting...
==> Executing... Failed to locate the file on the filesystem copying /tmp/postgresql-9.4-1201.jdbc41.jar to
/opt/jboss/wildfly/modules/org/postgresql/main/postgresql-9.4-1201.jdbc41.jar:
/tmp/postgresql-9.4-1201.jdbc41.jar (Permission denied)
What permissions are required, and where do I set the permission(s)?
Thanks
It seems the JAR file is not readable by the jboss user (the user comming from parent image). The postgresql-9.4-1201.jdbc41.jar is added under the root user - find details in this GitHub discussion.
You could
either add permissions to JAR file before adding it to the image
or add permissions to JAR file in the image after the adding
or change ownership of the file in the image
The simplest solution could be the first one. The other 2 solutions need also switching user to root (USER root in dockerfile) and then back to jboss.
Here a advice : make a cli file like this :
connect
module add --name=sqlserver.jdbc --resources=#INSTALL_FOLDER#/libext/jtds-1.3.1.jar --dependencies=javax.api,javax.transaction.api
/subsystem=datasources/jdbc-driver=sqlserver:add(driver-module-name=sqlserver.jdbc,driver-name=sqlserver,driver-class-name=#JDBC_DRIVER#)
/subsystem=datasources/data-source=#DATASOURCENAME#:add(jndi-name=java:jboss/#JNDI_NAME#,enabled="true",use-java-context="true",driver-name=sqlserver,connection-url="#JDBC_URL#",user-name=#JDBC_USER#,password=#JDBC_PASSWORD#,validate-on-match=true,background-validation=true)
replace #VAR# by our own value... and It should work!
Be caution than JBOSS/Wildfly 10 think relatively for jar --resources by default but wildfly 8 think absolute path this could make you weird ! ;-)
cheers!

VanillaSoftwareProcess Entity does not work in Apache Brooklyn

I have the last Apache Brooklyn (24.08.2015), Version: 0.8.0-SNAPSHOT, and when I am trying the example of the blueprint which is here: https://brooklyn.incubator.apache.org/v/latest/yaml/custom-entities.html
name: Simple Netcat Server Example
location: localhost
services:
- type: brooklyn.entity.basic.VanillaSoftwareProcess
name: Simple Netcat Server
launch.command: |
echo hello | nc -l 4321 &
echo $! > $PID_FILE
# The following overrides demonstrate the use of a custom shell environment as well as
# check-running and stop commands. These are optional; default behavior will "do the
# right thing" with the pid file automatically.
env: { CHECK_MARKER: "checkRunning", STOP_MARKER: "stop" }
checkRunning.command: echo $CHECK_MARKER >> DATE && test -f "$PID_FILE" && ps -p `cat $PID_FILE` >/dev/null
stop.command: echo $STOP_MARKER >> DATE && test -f "$PID_FILE" && { kill -9 `cat $PID_FILE`; rm /tmp/vanilla.pid; }
# can also define download.url, in which case the launch command defaults to ./start.sh in that (archive) file
When I tried to create the application with the Apache Brooklyn, I get an Internal error. I debugged the application, and the Exception I get is the following (PlanToSpecFactory.java):
java.lang.UnsupportedOperationException: Deployment plan item
org.apache.brooklyn.camp.spi.pdp.Service#62abec8e[name=Simple Netcat
Server,description=,serviceType=brooklyn.entity.basic.VanillaSoftwareProcess,characteristics=[],customAttributes={launch.command=echo
hello | nc -l 4321 & echo $! > $PID_FILE ,
env={CHECK_MARKER=checkRunning, STOP_MARKER=stop},
checkRunning.command=echo $CHECK_MARKER >> DATE && test -f "$PID_FILE"
&& ps -p cat $PID_FILE >/dev/null, stop.command=echo $STOP_MARKER
DATE && test -f "$PID_FILE" && { kill -9 cat $PID_FILE; rm /tmp/vanilla.pid; }}] cannot be matched
The trace in debug.log
DEBUG o.a.b.c.plan.PlanToSpecFactory
[brooklyn-jetty-server-8443-qtp1119923741-24]: Plan could not be
transformed; failure will be propagated (other transformers tried =
[]): [java.lang.IllegalArgumentException: Transformer for Brooklyn
OASIS CAMP interpreter gave an error creating this plan]
Any idea why? In the past this has worked
(I would like to post in the mailing list of Apache Brooklyn, but I get an error and I can not contact nobody)
The latest SNAPSHOT versions went through an heavy refactoring to change the package name to org.apache.brooklyn.*. That's probably why your version of Brooklyn cannot find the VanillaSoftwareProcess anymore.
Based on the Github repository, this entity is now located here: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess

Categories