A simple Docker Compose Demo for Spring Cloud Project .
-
build maven project and push them into docker by running "build-images.sh"
if you are successful , you can find this :
-
running project by using docker-compose :
docker-compose up -d
if you are successful , you can find this :
and you can find container list in your Docker pannel :
-
stop all the project by running :
docker-compose down
-
if you changed the code , plz run :
docker-compose down ./rm-images.sh ./build-image.sh docker-compose up
the ./rm-images.sh will remove the Image from Docker :
the ./build-image.sh will package your project and upload it to Docker .
before you run ./build-image.sh , your Docker pannel should be look like this :
after your run ./build-image.sh , your Docker pannel should be look like this :
-
plz pay attention , if you want to debug in IDEA , you need set your hosts file :
127.0.0.1 docker-compose-eureka 127.0.0.1 docker-compose-config 127.0.0.1 docker-compose-gateway 127.0.0.1 demo-api-a 127.0.0.1 demo-api-b
But jut running in Docker , you do not need set this .
-
Eureka pannel should be look like this :
-
config server should be look like this :
-
visit demo-api-a throw zuul gateway should be look like this :
-
visit demo-api-b throw zuul gateway should be look like this :
-
simply visit http://localhost:2333/demo-api-a/write
-
go to /Volumes
-
use ls order , and you can find a file named demo-api-a.txt (after the container is dead , this file will still exist)
-
simply visit http://localhost:2333/demo-api-a/read
-
go to /Volumes
-
use ls order , and you can find a file named demo-api-a-data.txt , which data is coming from /Volumes/demo-api-a.txt