This project is a sample for running the following web application on docker containers.
- Front-End Projects
- Back-End Projects
Perform the following steps:
- Install Docker in this command.
yum install docker-ce
- Install Docker Compose.
Perform the following steps:
- Build the
docker-compose.yml
in Docker Compose. Set a yml file with the-f
option. For Spring Boot, setdocker-compose_springboot.yml
.ex)docker-compose -f [File Name] build --no-cache
docker-compose -f docker-compose_springboot.yml build --no-cache
- Start containers in Docker Compose.
ex)
docker-compose -f [File Name] up -d
docker-compose -f docker-compose_springboot.yml up -d
In this sample, you can change the web container from Vue.js to React.js. To change the container, edit the following source:
Before
services:
web:
build: ./web/vue
container_name: web-server
After
services:
web:
build: ./web/react
container_name: web-server
Start a bash session on a running container in the following command.
- Web Container
docker exec -it web-server /bin/bash
- Application Container
docker exec -it app-server /bin/sh docker logs -f app-server
- Database Container
Show tables and select stored datas.
docker exec -it db-server psql -U testusr testdb docker exec -it db-server /bin/sh pg_dump --inserts -U testusr testdb
# show tables \dt; # select BOOK table select * from "BOOK"; # exit \q
This command can stop a running container.
docker-compose -f [File Name] stop
ex)
docker-compose -f docker-compose_springboot.yml stop
Also, the next command can delete the stopped container.
docker-compose -f [File Name] rm
ex)
docker-compose -f docker-compose_springboot.yml rm
The follwing figure is the map of this sample project.
- docker-webapp-sample
+ app … Application Container
- aspnetcore … Dockerfile for ASP.NET Core.
- rails … Dockerfile for Ruby on Rails.
- springboot … Dockerfile for Spring Boot.
- golang … Dockerfile for Golang Echo.
+ db … Database Container
+ web … Web Container
- vue
- react
- docker-compose_aspnetcore.yml … YAAML file for ASP.NET Core.
- docker-compose_rails.yml … YAAML file for Ruby on Rails.
- docker-compose_springboot.yml … YAAML file for Spring Boot.
- docker-compose_golang.yml … YAAML file for Golang Echo.
The License of this sample is MIT License.