Passing Java APM Agent settings in Docker - spring-boot

I monitor my jar using Elastic APM Agent, i run these commands manually :
java -javaagent:../infrastructure/agent/apm-agent.jar \
-Delastic.apm.service_name=server \
-Delastic.apm.server_urls=http://${APM_HOST}:8200 \
-Delastic.apm.application_packages=package.coù \
-jar ./target/server-0.0.1-SNAPSHOT.jar &
Now , i want to pass these parameters using docker run , i create the image and i try with this command to pass these settings , but the application is not starting
docker run --name app -e CATALINA_OPTS='-Dspring.config.location=/usr/local/tomcat/application-recette.properties,/usr/local/tomcat/application.yml'
-e CATALINA_OPTS='-Delastic.apm.service_name=server'
-e CATALINA_OPTS='-Delastic.apm.server_urls=http://10.128.0.4:8200'
-e CATALINA_OPTS='-Delastic.apm.application_packages=package.com'
-d -p 9000:8080 image:v1
any idea to resolve this ?
Thanks

actually there are many reasons why your app not starting depending on how you setup and configured your ELK stack , but for me I did the following and it's working fine :
shipped application.jar and apm-agent.jar via Dockerfile and run them inside container :
FROM openjdk:8-jre-alpine
COPY javaProjects/test-apm/target/test-apm-0.0.1-SNAPSHOT.jar /app.jar
COPY elastic-apm-agent-1.19.0.jar /apm-agent.jar
CMD ["/usr/bin/java","-javaagent:/apm-agent.jar", "-Delastic.apm.service_name=my-cool-service -Delastic.apm.application_packages=main.java -Delastic.apm.server_urls=http://localhost:8200","-jar", "/app.jar"]
create image from this Dockerfile:
docker build -t test-apm:latest ./
run the created image :
docker run --network host -p 8080:8080 test-apm:latest
note my apm-server and ELK-stack was running on my host machine ,
I think if you do the same and make little changes to mach you environments it should work fine ,

Related

mc: <error> while trying to run bitnami/minio-client the container is exiting within a seconds

docker run -it --name mc3 dockerhub:5000/bitnami/minio-client
08:05:31.13
08:05:31.14 Welcome to the Bitnami minio-client container
08:05:31.14 Subscribe to project updates by watching https://github.com/bitnami/containers
08:05:31.14 Submit issues and feature requests at https://github.com/bitnami/containers/issues
08:05:31.15
08:05:31.15 INFO  ==> ** Starting MinIO Client setup **
08:05:31.16 INFO  ==> ** MinIO Client setup finished! ** mc: Configuration written to /.mc/config.json. Please update your access credentials.
mc: Successfully created /.mc/share.
mc: Initialized share uploads /.mc/share/uploads.json file.
mc: Initialized share downloads /.mc/share/downloads.json file.
**mc: /opt/bitnami/scripts/minio-client/run.sh is not a recognized command. Get help using --help flag.
dockerhub:5000/bitnami/minio-client - name of the image
It would be great if someone reach out to help me how to solve this issue as I'm stuck here for more than 2 days
MinIO has two components:
Server
Client
The Server runs continuously, as it should, so it can serve the data.
On the other hand the client, which you are trying to run, is used to perform operations on a running server. So its expected for it to run and then immediately exit as its not a daemon and its not meant to run forever.
What you want to do is to first launch the server container in background (using -d flag)
$ docker run -d --name minio-server \
--env MINIO_ROOT_USER="minio-root-user" \
--env MINIO_ROOT_PASSWORD="minio-root-password" \
minio/minio:latest
Then launch the client container to perform some operation, for example making/creating a bucket, which it will perform on the server and exit immidieatly after which it will clean up the client container (using -rm flag).
$ docker run --rm --name minio-client \
--env MINIO_SERVER_HOST="minio-server" \
--env MINIO_SERVER_ACCESS_KEY="minio-root-user" \
--env MINIO_SERVER_SECRET_KEY="minio-root-password" \
minio/mc \
mb minio/my-bucket
For more information please checkout the docs
Server: https://min.io/docs/minio/container/operations/installation.html
Client: https://min.io/docs/minio/linux/reference/minio-mc.html

How to Run ROS 1 / ROS2 in frdmrobotics/playground in Docker on Windows and Connect via VcXsrv

I am trying to run the frdmrobotics/playground Docker Image like in this tutorial.
And also Connect the Gui via VcXsrv.
I tried to pull the Image but already only got errors.
Also I have no idea how I should connect VcXsrv from inside the Image
The Problem with Pulling was solved by updating Docker for Windows by starting it and letting it search for an Update.
After a Restart I could Pull the image with docker pull frdmrobotics/playground.
For starting a Container of the Image
docker run -it frdmrobotics/playground
works, but from the Tutorial
cd to the desired development folder e.g.
cd c:/rosProgramming
and then use:
docker run -dt --name robot_env --restart unless-stopped -v %cd%:/root/workspace frdmrobotics/playground
That starts the Container which can then be connected to by using:
docker exec -it robot_env bash
For Connecting VcXsrv I found the Info that I had to set some things in the Image:
export DISPLAY=192.168.105.1:0.0
export LIBGL_ALWAYS_INDIRECT=1
The needed IP Address in that command I got via ipconfig, it is the one which is marked with "(WSL)".
After that when I started a Programm it Opened in my VcXsrv Instance
After that you can use:
cd /root/code/ros1
to navigate to the ros1 environment

can't reach .net core web app using docker (windows)

This is driving me crazy:
I created a new .Net Core Web App from VS2019, adding support for docker (linux containers).
Everything works fine: if I start the debugger from VS the image is built, the container is started and the web app is available at http://localhost:32772/weatherforecast.
Then I clean it all up, and try to build and run manually:
docker build -t webapp2 --file webapplication2/Dockerfile .
docker run --name webapp2 -p 5000:5000 -t webapp2
(or even docker run --name webapp2 -p 5000:5000 -e "ASPNETCORE_ENVIRONMENT=Development" -t webapp2)
Build runs successfully, and (apparently) run command works fine too:
But...surprise...This way I cannot reach the app anymore (at http://localhost:5000/weatherforecast)!
Tried almost anything, use internal ip address from inspect, changing ports and run commands, adding -e "ASPNETCORE_URLS=https://+:443;http://+:80", nothing seems to work.
So the question is: what kind of magic we have behind the VS debug command?
I tried to see what's there but I don't see anything useful:
docker run -dt -v "C:\Users\carlo\vsdbg\vs2017u5:/remote_debugger:rw" -v "C:\Progetti\prove\docker\API\WebApplication2:/app" -v "C:\Progetti\prove\docker\API:/src/" -v "C:\Users\carlo\.nuget\packages\:/root/.nuget/fallbackpackages2" -v "C:\Program Files\dotnet\sdk\NuGetFallbackFolder:/root/.nuget/fallbackpackages" -e "DOTNET_USE_POLLING_FILE_WATCHER=1" -e "ASPNETCORE_LOGGING__CONSOLE__DISABLECOLORS=true" -e "ASPNETCORE_ENVIRONMENT=Development" -e "NUGET_PACKAGES=/root/.nuget/fallbackpackages2" -e "NUGET_FALLBACK_PACKAGES=/root/.nuget/fallbackpackages;/root/.nuget/fallbackpackages2" -P --name WebApplication2 --entrypoint tail webapplication2:dev -f /dev/null
Thanks!
Passing the port to docker run doesn't somehow override the port he application is running on. All you're saying is that you want port 5000 on the container exposed as port 5000 on the network. However, you app is running on 80, so that buys you nothing. You'd need -p 80:5000.
The ASPNETCORE_URLS environment variable is just way to configure the URLs of your app, which in a container is going to bind to https://+:443;http://+:80 by default. Setting the environment variable to the same thing again does nothing. You could do something like http://+:5000, which would then change the internal port to 5000 instead of 80, and then your original docker run command would have worked, because there's something actually running on port 5000.

Windows GUI application in Docker containers

I have created a simple Hello World GUI application. This is the docker file,
FROM microsoft/windowsservercore:10.0.14393.2007
ADD ./TestDocker/* /
CMD c:\TestDocker.exe
I build it using:
docker build -t test-docker-i .
I run it using:
docker run -it test-docker-i
I see TestDocker.exe in the task manager, but no GUI shown. Can anyone point me if i am doing anything wrong?

Error "Docker: invalid publish opts format " runing Graphviz docker container on Mac Os

I'm completely new to docker and am using it for the first time.
I have installed Docker Desktop for Mac OS and run the 'Hello-world' container successfully. I am now trying to run this 'omerio/graphviz-server' from https://hub.docker.com/r/omerio/graphviz-server (which is what I really want Docker for) and although the 'docker pull omerio/graphviz-server' command completes successfully:
devops$ docker pull omerio/graphviz-server
Using default tag: latest
latest: Pulling from omerio/graphviz-server
863735b9fd15: Pull complete
4fbaa2f403df: Pull complete
44be94a95984: Pull complete
a3ed95caeb02: Pull complete
ae092b5d3a08: Pull complete
d0edb8269c6a: Pull complete
Digest: sha256:02cd3e2355526a927e951a0e24d63231a79b192d4716e82999ff80e0893c4adc
Status: Downloaded newer image for omerio/graphviz-server:latest
the command to start the container (given on https://hub.docker.com/r/omerio/graphviz-server): 'docker run -d -p : omerio/graphviz-server' gives me the error message:
devops$ docker run -d -p : omerio/graphviz-server
docker: invalid publish opts format (should be name=value but got ':').
See 'docker run --help'.
Searching for this error message returns no information at all. I see that the container in question was last updated over 3 years ago - could it be an old format that Docker no longer supports?
-p option of docker run command binds ports between host and container (see docs), and its usage is most of the time the following :
docker run <other options> \
-p <port on the host>:<port in the container> \
<my_image> <args>
As for your example : it seems that running the image needs an argument (the port in the container). Let's choose 8080 for example (that means port 8080 will be used by the application inside the container).
If you want to access it directly on your host (via localhost), you should bind 8080 port (in the container, the port we chose previously) to any available port on your host (let's say 8081), like this :
docker run \
-p 8081:8080 \
omerio/graphviz-server 8080
You should now be able to access the application (port 8080 of the application running in the container) from your host via localhost:8081.

Resources