Slides
-
Installed as part of Docker Toolbox or github.com/docker/compose/releases
-
docker-compose -v
-
docker-compose --help
. Explainup
,ps
,down
,scale
,restart
,port
-
Create a directory
helloweb
-
Create Compose file in
helloweb
directory:vi docker-compose.yml
version: '3'
services:
web:
image: jboss/wildfly
volumes:
- ~/deployments:/opt/jboss/wildfly/standalone/deployments
ports:
- 8080:8080
-
Talk about how
deployments
directory is automatically created -
Explain
web
,image
,volumes
,ports
-
Compare with Docker CLI
Run the commands:
docker-compose up -d
docker-compose logs -f
cp docker-for-java-master/chapter2/webapp.war ~/deployments
curl http://localhost:8080/webapp/resources/persons
docker-compose down
-
Create a directory
travel
version: '3'
services:
web:
image: arungupta/couchbase-javaee:travel
environment:
- COUCHBASE_URI=db
ports:
- 8080:8080
- 9990:9990
depends_on:
- db
db:
image: arungupta/couchbase:travel
ports:
- 8091:8091
- 8092:8092
- 8093:8093
- 11210:11210
-
Two images
web
anddb
-
Explain
depdends_on
- container and app starting sequence -
COUCHBASE_URI
- show code -
Start application:
docker-compose up -d
-
Show logs:
docker-compose logs -f
-
Access application:
curl http://localhost:8080/airlines/resources/airline
-
Shutdown application:
docker-compose down
By default, service names is <project-name>_<service-name>_<service-number>
Start using docker-compose -p myapp up -d
docker-compose ps
shows no services
docker-compose -p myapp ps
shows services
Copy the following in docker-compose.override.yml
:
version: "3"
services:
web:
ports:
- 80:8080
-
Run application:
docker-compose up -d
. -
App now accessible at curl http://localhost/webapp/resources/persons
-
Shutdown using
docker-compose down