I have some problems while building an automated build for my web application, using mySQL.
I will use the example from https://github.com/ehazlett/docker-sample-java-mysql-tomcat.
This is my fig.yml file:
db:
image: orchardup/mysql
environment:
MYSQL_USER: java
MYSQL_PASSWORD: java
MYSQL_DATABASE: javatest
ports:
- "3306"
dbinit:
image: orchardup/mysql
entrypoint: /bin/bash
volumes:
- .:/host
command: -c "sleep 4; mysql -u java --password=java -h mysql javatest < /host/init.sql; exit 0"
links:
- db:mysql
app:
build: .
links:
- dbinit
- db:mysql
ports:
- "8080"
And this the simple Dockerfile:
FROM ehazlett/tomcat7
COPY dbtest /opt/tomcat/webapps/dbtest
Now, in order to manually run it I should run these commands:
docker run -d -P -e MYSQL_USER=java -e MYSQL_PASSWORD=java -e MYSQL_DATABASE=javatest --name mysql orchardup/mysql
docker run -ti --rm --link mysql:mysql -v $(pwd):/host --entrypoint /bin/bash orchardup/mysql -c "sleep 4; mysql -u java --password=java -h mysql javatest < /host/init.sql; exit 0"
docker build -t javatest .
docker run -ti -P --rm --link mysql:mysql javatest
I would like the the applciation would run just by typing:
docker-compose up
Is there any way to do that? Thank you for your help.