Failed to bind properties under 'server.port' to java.lang.Integer - spring-boot

Some time ago I faced with such issue:
Failed to bind properties under 'server.port' to java.lang.Integer:
Property: server.port
Value: $PORT
Origin: "server.port" from property source "systemProperties"
Reason: failed to convert java.lang.String to java.lang.Integer
Action:
Update your application's configuration
I tried to run my docker container in DigitalOcean.
I observed some similar topics here and I tried to apply advices. For instance I added server.port=${PORT:8080} to my application.properties but it didn't work for me.
Here's my docker run command:
docker run -p 8080:8080 --name nostalgia --env-file vars.txt --rm -it registry.digitalocean.com/alex-registry/nostalgia
And this is my vars.txt (only one variable at the moment):
PORT=8080
Also I should say that I tried another form of command:
docker run -p 8080:8080 --name nostalgia -e PORT=8080 --rm -it registry.digitalocean.com/alex-registry/nostalgia
But result is the same.
What should I do next to overcome this issue and successfully launch the container? Thanks for your answers!!!

Related

Docker Issue : Cannot run the container (repository does not exist or may require 'docker login')

After I devise a Spring Boot project with the usage of MinIo, I tried to run it in Docker but I have an issue.
Here is my docker-compose.yaml file
version: '3.8'
services:
minio:
image: minio/minio:latest
container_name: minio
environment:
MINIO_ACCESS_KEY: "minioadmin"
MINIO_SECRET_KEY: "minioadmin"
volumes:
- ./data:/data
ports:
- 9000:9000
- 9001:9001
I firstly run this command docker-compose up -d.
Then I run docker ps -a to check if it is located in container. After that, I run this command docker run <container-id> (a07fdf1ef8c4), here is a message shown below.
Unable to find image 'a07fdf1ef8c4:latest' locally
docker: Error response from daemon: pull access denied for a07fdf1ef8c4, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
I also run this option shown below nothing changed.
C:\Users\host\IdeaProjects\SpringBootMinio>docker run -p 9000:9000 9001:9001 minio/minio:latest
Unable to find image '9001:9001' locally
docker: Error response from daemon: pull access denied for 9001, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
Even if I run the command docker login, I couldn't fix it.
How can I solve it out?
1st Error
docker run <container-id> - That is not how you run a container with Docker. When you run docker-compose up -d, it already starts the containers; in this case it's MinIO.
The docker run function requires an image name as the argument. So when you do docker run <container-id>, it tries to find an image with the container ID, which doesn't exist.
So when you do docker-compose up -d, it starts minio. You do not need to start it again.
2nd Error
When you run docker run -p 9000:9000 9001:9001 minio/minio:latest, you are basically saying that the image name is 9001:9001. But no such image exists. If you want to expose another port, just do docker run -p 9000:9000 -p 9001:9001 minio/minio:latest. For every single port you want to expose, just do -p and enter the port mapping.

Microservice java property not set in application.properties

I have the following line in micros1-mvc microservice application.properties: eureka.client.serviceUrl.defaultZone=${EUREKA_SERVER}
I execute the microservice inside the container with:
sudo docker run -p 8081:8081 --network mynetw --env JAVA_OPTS="-DEUREKA_SERVER=http://eurekaserver:8761/eureka" micros1-mvc
And when the microservice tries to connect with Eureka it says:
overyClient :
DiscoveryClient_SERVICEASERVICE/1754e70517a8:serviceaservice:8081 -
was unable to refresh its cache! This periodic background refresh will
be retried in 30 seconds. status = There is no known eureka server;
cluster server list is empty stacktrace =
com.netflix.discovery.shared.transport.TransportException: There is no
known eureka server; cluster server list is empty at
com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:108)
at
com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134)
at
com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137)
at
com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
at
com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134)
at
com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:1101)
at
com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:1014)
at
com.netflix.discovery.DiscoveryClient.refreshRegistry(DiscoveryClient.java:1531)
It looks like the microservice properties file doesn't receive the specified value in docker execution
After some searching, I came across the fact that JAVA_OPTS are very specific to Catalina (Tomcat). Looking in the bin folder of a tomcat install you'll find a shell script that handles passing JAVA_OPTS into the exec lines.
A Dockerfile like:
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","${JAVA_OPTS}","-jar","/app.jar"]
With:
docker run -p 9000:9000 -e JAVA_OPTS=-Dserver.port=9000 myorg/myapp
Fails. This fails because the ${} substitution requires a shell. The exec form does not use a shell to launch the process, so the options are not applied. You can get around that by moving the entry point to a script or by explicitly creating a shell in the entry point. The following example shows how to create a shell in the entry point:
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -jar /app.jar"]
You can then launch this app by running the following command:
docker run -p 8080:8080 -e "JAVA_OPTS=-Ddebug -Xmx128m" myorg/myapp

How to launch graphite docker container locally?

I am following this wiki to setup some performance numbers for my testing I am doing. I needed to setup graphite to see my numbers.
So I ran this command as mentioned in the wiki on my mac -
docker run -d --name graphite -p 80:80 -p 2003-2004:2003-2004 -p 2023-2024:2023-2024 -p 8125:8125/udp -p 8126:8126 graphiteapp/graphite-statsd
Below is what I got:
> docker run -d --name graphite -p 80:80 -p 2003-2004:2003-2004 -p 2023-2024:2023-2024 -p 8125:8125/udp -p 8126:8126 graphiteapp/graphite-statsd
Unable to find image 'graphiteapp/graphite-statsd:latest' locally
latest: Pulling from graphiteapp/graphite-statsd
aad63a933944: Pull complete
9b6d24804914: Pull complete
5f9542cd4cb1: Pull complete
09c978daf42b: Pull complete
Digest: sha256:18fbffd024cd540c7a57febfaa38c3dc5513f05db2263300209deb2a8ecd923c
Status: Downloaded newer image for graphiteapp/graphite-statsd:latest
ac248794f9cdea3bd1ab65659ec321d0aa0111de3f151c5e206b6503202a35e3
Now I ran my program which is pushing my metrics to graphite and then I was trying to configure my grafana dashboard by launching grafana docker container with below command as shown in that same wiki:
docker run -d --name -p 3000:3000 grafana grafana/grafana
But I got an error once I executed above command:
> docker run -d --name -p 3000:3000 grafana grafana/grafana
Unable to find image '3000:3000' locally
docker: Error response from daemon: pull access denied for 3000, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
This is the first time I am working with docker so have some issues setting it up and I have already installed docker on my mac. Any idea what is wrong here?
To explain the problem in your command.
Your command
docker run -d --name -p 3000:3000 grafana grafana/grafana
As you can see, --name, no value is specified and that's why it is picking up random value for the image. Use the below command. Meaning of the flags are
--name => Name of the container which is grafana in this case
-p => Publish a container's port(s) to the host, which is 3000:3000 over here
-d => Run container in background and print container ID
docker run -d -p 3000:3000 --name grafana grafana/grafana
Logs of the command:
docker run -d -p 3000:3000 --name grafana grafana/grafana
Unable to find image 'grafana/grafana:latest' locally
latest: Pulling from grafana/grafana
cbdbe7a5bc2a: Already exists
ed18d4ca725a: Pull complete
5ac007dea7db: Pull complete
33b8e7fbf663: Pull complete
09cd2fb04616: Pull complete
990c0b335bdb: Pull complete
Digest: sha256:4bbfcbf9372e1022bf51b35ec1aaab04bf46e01b76a1d00b424f45b63cf90967
Status: Downloaded newer image for grafana/grafana:latest
7748b112f5004a18144152ac7330749b83120914bb0ab0d3a7112ea16368bfa2
Just set --name grafana.
docker run -d --name grafana -p 3000:3000 grafana/grafana
Unable to find image 'grafana/grafana:latest' locally
latest: Pulling from grafana/grafana
cbdbe7a5bc2a: Already exists
ed18d4ca725a: Pull complete
....
....

how to run docker with keycloak image as a daemon in prod environment

I am using docker to run my Keycloak server in aws production environment. The problem is keycloak uses wildfly which is constant running. Because of this I cannot close the shell. I am trying to find a way to run docker as a daemon thread.
The command I use to run docker
docker run -p 8080:8080 jboss/keycloak
Just user docker's detach option -d.
docker run -p 8080:8080 -d jboss/keycloak

Passing Elasticsearch and Kibana config file to docker containers

I have found a docker image devdb/kibana which runs Elasticsearch 1.5.2 and Kibana 4.0.2. However I would like to pass into this docker container the configuration files for both Elasticsearch (i.e elasticsearch.yml) and Kibana (i.e config.js)
Can I do that with this image itself? Or for that would I have to build a separate docker container?
Can I do that with this image itself?
yes, just use Docker volumes to pass in your own config files
Let say you have the following files on your docker host:
/home/liv2hak/elasticsearch.yml
/home/liv2hak/kibana.yml
you can then start your container with:
docker run -d --name kibana -p 5601:5601 -p 9200:9200 \
-v /home/liv2hak/elasticsearch.yml:/opt/elasticsearch/config/elasticsearch.yml \
-v /home/liv2hak/kibana.yml:/opt/kibana/config/kibana.yml \
devdb/kibana
I was able to figure this out by looking at your image Dockerfile parents which are: devdb/kibana→devdb/elasticsearch→abh1nav/java7→abh1nav/baseimage→phusion/baseimage
and also taking a peek into a devdb/kibana container: docker run --rm -it devdb/kibana find /opt -type f -name *.yml.
Or for that would I have to build a separate docker container?
I assume you mean build a separate docker image?. That would also work, for instance the following Dockerfile would do that:
FROM devdb/kibana
COPY elasticsearch.yml /opt/elasticsearch/config/elasticsearch.yml
COPY kibana.yml /opt/kibana/config/kibana.yml
Now build the image: docker build -t liv2hak/kibana .
And run it: docker run -d --name kibana -p 5601:5601 -p 9200:9200 liv2hak/kibana

Resources