i wanted to run this java app through docker:
https://github.com/ByteHamster/PSE
the docker-compose.yml file looks like:
simulation:
build: .
dockerfile: simulationDockerfile
environment:
- DISPLAY
expose:
- 12868
- 12869
- 12870
- 12871
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
monitor:
build: .
dockerfile: monitorDockerfile
environment:
- DISPLAY
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
links:
- simulation
when i run docker-compose build i get this error message:
(root) Additional property monitor is not allowed
what is the valid yml to make this program run?
thanks guys
version: '2'
services:
simulation:
build:
context: .
dockerfile: simulationDockerfile
environment:
- DISPLAY
expose:
- 12868
- 12869
- 12870
- 12871
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
monitor:
build:
context: .
dockerfile: monitorDockerfile
environment:
- DISPLAY
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
links:
- simulation
had to make the following changes so make it work
thanks #David Maze
Related
I just started using docker-compose and I am enjoying it.
I recently just created my first docker-compose file that simply connects sonarqube and postgres. Inside my docker-compose.yml file, whenever I define the database service with any other name besides "db", my docker-compose does not run successfully.
This is the error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader#277050dc-org.sonar.db.DefaultDatabase': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Fail to connect to database
This is the code in my docker compose file:
version: "3"
services:
sonarqube:
image: sonarqube
expose:
- 9000
ports:
- "127.0.0.1:9000:9000"
networks:
- sonarnet
environment:
- sonar.jdbc.url=jdbc:postgresql://db:5432/sonar
- sonar.jdbc.username=sonar
- sonar.jdbc.password=sonar
volumes:
- sonarqube_conf:/opt/sonarqube/conf
- sonarqube_data:/opt/sonarqube/data
- sonarqube_extensions:/opt/sonarqube/extensions
- sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins
db:
image: postgres
networks:
- sonarnet
ports:
- "5432:5432"
environment:
- POSTGRES_USER=sonar
- POSTGRES_PASSWORD=sonar
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data
networks:
sonarnet:
volumes:
sonarqube_conf:
sonarqube_data:
sonarqube_extensions:
sonarqube_bundled-plugins:
postgresql:
postgresql_data:
Is there anything special about the name "db"? Are there any conventions/rules for defining services in docker-compose?
Thank you.
You have to change the service name also within the sonarqube's connections string.
here, replace the string db with how you renamed the service for postgres (these have to match):
environment:
- sonar.jdbc.url=jdbc:postgresql://db:5432/sonar
# ^ here
It is needed, because docker-compose registers hostnames (defined by service names) for the stack so they are always dynamically accessible.
Update your docker-compose with depends_on property to let docker know that db should be created firstly:
version: "3"
services:
sonarqube:
image: sonarqube
expose:
- 9000
ports:
- "127.0.0.1:9000:9000"
networks:
- sonarnet
environment:
- sonar.jdbc.url=jdbc:postgresql://db:5432/sonar
- sonar.jdbc.username=sonar
- sonar.jdbc.password=sonar
volumes:
- sonarqube_conf:/opt/sonarqube/conf
- sonarqube_data:/opt/sonarqube/data
- sonarqube_extensions:/opt/sonarqube/extensions
- sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins
depends_on:
- db
db:
image: postgres
networks:
- sonarnet
ports:
- "5432:5432"
environment:
- POSTGRES_USER=sonar
- POSTGRES_PASSWORD=sonar
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data
networks:
sonarnet:
volumes:
sonarqube_conf:
sonarqube_data:
sonarqube_extensions:
sonarqube_bundled-plugins:
postgresql:
postgresql_data:
I have the following Docker project running on a Linux VM. When I log into localhost, thanks to the website, I can save a photo on the Tomcat container on the server. I want to access the images uploaded to Tomcat to make a backup. How can I do? Why is my code not working?
- ./volumes/tomcat:/usr/local/tomcat/webapps/
Below I report all my project:
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/https/localhost-rsa-cert.pem
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/https/localhost-rsa-key.pem
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/https/server.xml
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/tomcat/Dockerfile
FROM tomcat:9.0.63-jdk11
LABEL Author="Nome Cognome"
EXPOSE 8080
EXPOSE 8443
COPY ./serverfile/*.war /usr/local/tomcat/webapps/
CMD ["catalina.sh", "run"]
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/docker-compose.yaml
version: '3.8'
services:
postgresql-postgis:
...
pgadmin:
...
tomcat:
build: ./tomcat
image: image-tomcat-eb:v.1.0
container_name: container-tomcat-eb
ports:
- 6003:8080
- 7003:8443
volumes:
- ./https/localhost-rsa-cert.pem:/usr/local/tomcat/ssl/localhost-rsa-cert.pem
- ./https/localhost-rsa-key.pem:/usr/local/tomcat/ssl/localhost-rsa-key.pem
- ./https/server.xml:/usr/local/tomcat/conf/server.xml
- ./volumes/tomcat:/usr/local/tomcat/webapps/
depends_on:
- postgresql-postgis
- pgadmin
restart: on-failure
networks:
- eb
mysql:
...
phpmyadmin:
...
php:
...
volumes:
data-postgresql:
data-mysql:
networks:
eb:
In my Windows 10 machine I have a Java app and create Postgresql images on Docker using the following configuration:
docker-compose.yml:*
version: '2.0'
services:
postgresql:
image: postgres:11
ports:
- "5432:5432"
expose:
- "5432"
environment:
- POSTGRES_USER=demo
- POSTGRES_PASSWORD=******
- POSTGRES_DB=demo_test
And I use the following command to compose images:
cd postgresql
docker-compose up -d
Although pgadmin container is working on Docker, postgres container is generally restarting state and sometines seems to be running state for a second. When I look at that container log, I see I encounter the following errors:
2021-03-16 09:00:18.526 UTC [82] FATAL: data directory "/data/postgres" has wrong ownership
2021-03-16 09:00:18.526 UTC [82] HINT: The server must be started by the user that owns the data directory.
child process exited with exit code 1
*initdb: removing contents of data directory "/data/postgres"
running bootstrap script ... The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
I have tried to apply several workaround suggestions e.g. PostgreSQL with docker ownership issue, but none of them is working. So, how can I fix this problem?
Update: Here is last status of my docker-compoese.yml file:
version: '2.0'
services:
postgresql:
image: postgres:11
container_name: "my-pg"
ports:
- "5432:5432"
expose:
- "5432"
environment:
- POSTGRES_USER=demo
- POSTGRES_PASSWORD=******
- POSTGRES_DB=demo_test
volumes:
- psql:/var/lib/postgresql/data
volumes:
psql:
As I already stated in my comment I'd suggest using a named volume.
Here's my docker-compose.yml for Postgres 12:
version: "3"
services:
postgres:
image: "postgres:12"
container_name: "my-pg"
ports:
- 5432:5432
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: "mydb"
volumes:
- psql:/var/lib/postgresql/data
volumes:
psql:
Then I created the psql volume via docker volume create psql (so just a volume without any actual path mapping).
I'm trying to create an image of a application that I'm creating from a Udemy course, it is a Java Spring-Boot REST application which uses MySQL database. Here's the problem: I've done the same steps as my teacher show on video, but for some reason, my docker can't run the image.
Here's the docker-compose.yml and Dockerfile and the logs:
docker-compose.yml
version: '3.4'
services:
db:
image: raphasalomao/restudemy
command: mysqld --default-authentication-plugin=mysql_native_password
restart: always
build:
context: .
dockerfile: Dockerfile
environment:
TZ: America/Sao_Paulo
MYSQL_ROOT_PASSWORD: docker
MYSQL_USER: docker
MYSQL_PASSWORD: docker
MYSQL_DATABASE: restudemy
ports:
- "3308:3306"
networks:
- udemy-network
restudemy:
image: raphasalomao/restudemy
restart: always
build: /Users/rapha/OneDrive/Documentos/Projetos/RestUdemy/02 RestWithSpringBoot
working_dir: /Users/rapha/OneDrive/Documentos/Projetos/RestUdemy/02 RestWithSpringBoot
environment:
TZ: America/Sao_Paulo
SPRING_BOOT_ENVIRONMENT: Production
volumes:
- ./02 RestWithSpringBoot:/Users/rapha/OneDrive/Documentos/Projetos/RestUdemy/02 RestWithSpringBoot
- ~/.m2:/root/.m2
ports:
- "8080:8080"
command: mvn clean spring-boot:run
links:
- db
depends_on:
- db
networks:
- udemy-network
networks:
udemy-network:
driver: bridge
Dockerfile:
FROM mysql:5.7.23
EXPOSE 3308
LOG:
/usr/local/bin/mvn-entrypoint.sh: 50: exec: mysqld: not found
I've tried to change the $PATH on wsl, use mysqld.exe instead of MySQL, update Windows, install docker and WSL again, but nothing works.
I found the problem, actually, this is the first time that I use docker, o don't know much about, but the problem was the mysql image, i change from "image: raphasalomao/restudemy" to "image: mysql:5.7"
This image "raphasalomao/restudemy" came from which Registry? DockerHub??
I Couldnt find this on DockerHub.
But based on the message, it appears to be a Maven related Image.
Why not use mysql Official Image?
I am trying to build a docker application with 3 containers:
troparo_app (web-service)
library_app (web-client)
troparo_db (postgres db)
Somehow, I am getting a 404 while trying to connect from the app to the webservice.
The webservice responds ok from host on:
http://localhost:8080/troparo_app/services
Tested it from SOAP UI and working just fine
for the web-client(library_app), I can't access the main page at:
http://localhost:8090/library-web-1.0-SNAPSHOT/login
but then I get a 404:
org.apache.cxf.transport.http.HTTPException: HTTP response '404: null' when communicating with http://localhost:8080/troparo_app/services/connect/ConnectService
My docker-compose below:
# Version of docker-compose
version: '3'
services:
# getting postgres DB
db:
image: postgres:11.1
#container_name: troparo_db
ports:
- 5432:5432
environment:
POSTGRES_USER: ocp
POSTGRES_PASSWORD: 123
POSTGRES_DB: troparo
POSTGRES_INITDB_ARGS: --data-checksums
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- pg-data:/var/lib/postgresql/data
networks:
- troparo
# getting troparo image
webservice:
image: troparo_app
container_name: troparo_app
build: .
ports:
- 8080:8080
depends_on:
- db
networks:
- troparo
# getting troparo image
webapp:
image: library_app
container_name: library_app
build: ../webo/library/.
ports:
- 8090:8080
depends_on:
- webservice
networks:
- troparo
volumes:
pg-data:
networks:
troparo:
Dockerfile for library_app:
FROM tomcat:9.0.14-jre8
RUN rm -rf /usr/local/tomcat/webapps/*
COPY ./library-web/target/library-web-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/library-web-1.0-SNAPSHOT.war
CMD ["catalina.sh","run"]
Dockerfile for troparo_app:
FROM tomcat:9.0.14-jre8
RUN rm -rf /usr/local/tomcat/webapps/*
COPY ./troparo-web/target/troparo_app.war /usr/local/tomcat/webapps/troparo_app.war
CMD ["catalina.sh","run"]
I connected to the client container and ping the service -> ok
I tried several combination for connecting to the webservice:
http://troparo_app:8080
http://localhost:8080
but all fails so far.
I am new to docker so I imagine there is something I forgot to configure in the network but I couldn't figure it out so far so if anyone can help, I d be really grateful !!
Thanks
After some more thoughts / testing, I finally have it working!!
The webservice is simply accessible on http://webservice:8080