Docker Community Forums

Share and learn in the Docker community.

Docker compose java and mysql

docker

(Crismon01) #1

Hi, i have this file compose:
and i have do a services that use the java code of LogIn.jar do do a query to a db, but in the compose i don’t know how to do the interaction with the shell, if i run this like container i use the exec to use the shell of java container but there?

version: '3.3'

services:
  db:
    container_name: dbContainer
    image: mysql:5.7
    volumes:
    - /home/crismon-01/Documenti/TESI/Docker/mysqlLogin/datas:/var/lib/mysql
    ports:
    - 3306
    environment:
     MYSQL_ROOT_PASSWORD: "root"
     MYSQL_USER: "root"
     MYSQL_PASSWORD: "root"
     MYSQL_DATABASE: "schema1"
  java:
    container_name: loginJava
    image: openjdk:8
    depends_on:
    - db
    volumes:
    - .:/usr/src/myapp 
    working_dir: /usr/src/myapp
    command: bash -c "cd /usr/src/myapp && java -jar LogIn.jar"  
    stdin_open: true
    tty: true