Docker ๋ช ๋ น ์ฐธ๊ณ
- ์กฐํ
docker ps -a
-a : ์ ์ง ์ค ํฌํจ
- ์ค์ง
docker stop <container-id/container-name>
- ์์
docker start <container-id/container-name>
- ์ฌ์์
docker restart <container-id/container-name>
- ์ ์
docker attach <container-id/container-name>
Postgrelsql 12.9-alpine Docker run
docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=<password> --name Postgresql postgres:12.9-alpine
- Postsql Volume ์์ฑ ๋ฐ ํ์ฌ ํ ๋ฌ๋
docker create volume postgresql-sample
* /var/lib/postgresql/data ์ ๋ฐ์ดํฐ๊ฐ ์ ์ฅ๋๊ธฐ ๋๋ฌธ์ ํด๋น ๊ฒฝ๋ก๋ฅผ ์ง์ ๋ฐ ์บก์ณ
docker run -d -p 5432:5432 -e POSTGRES_PASSWORD="{password}" -v postgresql-sample:/var/lib/postgresql/data --network boot-sample-network --name Postgresql postgres:12.9-alpine
์ดํ localhost:5432 ๋ก postgresql ์ ์.
-- ์ฌ์ฉ์ ์กฐํ
select * from pg_user;
-- ์ฌ์ฉ์ ์์ฑ
create user test password 'test';
-- ๋ฐ์ดํฐ ๋ฒ ์ด์ค ์์ฑ
create database test owner test
-- ๋ฐ์ดํฐ ๋ฒ ์ด์ค ์กฐํ
select datname from pg_database;
ํ ์คํธ์ฉ ํ ์ด๋ธ ์์ฑ
-- Drop table
-- DROP TABLE public.test_table;
CREATE TABLE public.test_table (
"name" varchar(200) NULL,
value varchar(200) NULL
);
COMMENT ON TABLE public.test_table IS 'test_table';
ํ ์คํธ์ฉ ๋ฐ์ดํฐ ์ฝ์
INSERT INTO public.test_table ("name",value) VALUES
('1','TEST_VALUE1'),
('2','TEST_VALUE2'),
('3','TEST_VALUE3'),
('4','TEST_VALUE4'),
('5','TEST_VALUE5'),
('6','TEST_VALUE6'),
('7','TEST_VALUE7'),
('8','TEST_VALUE8'),
('9','TEST_VALUE9'),
('10','TEST_VALUE10');
INSERT INTO public.test_table ("name",value) VALUES
('11','TEST_VALUE11'),
('12','TEST_VALUE12'),
('13','TEST_VALUE13'),
('14','TEST_VALUE14'),
('15','TEST_VALUE15'),
('16','TEST_VALUE16'),
('17','TEST_VALUE17'),
('18','TEST_VALUE18'),
('19','TEST_VALUE19'),
('20','TEST_VALUE20');
DB์ค๋น ์๋ฃ
Spring Boot 2.6.2 + jstl
- build.gradle ์ค์
plugins {
id 'org.springframework.boot' version '2.6.2'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.docker'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// ์ฌ์ฉ์ ์ถ๊ฐ
// dev tool ( ์ ์ ๋ฆฌ์์ค ์ฌ์์์์ด ์ ์ฉ )
implementation group: 'org.springframework.boot', name: 'spring-boot-devtools'
// mybatis-spring-boot
implementation group: 'org.mybatis.spring.boot', name: 'mybatis-spring-boot-starter', version: '2.1.4'
// log4j2
implementation group: 'org.bgee.log4jdbc-log4j2', name: 'log4jdbc-log4j2-jdbc4.1', version: '1.16'
// jdbc ( postgresql - jdbc driver )
implementation group: 'org.postgresql', name: 'postgresql', version: '42.3.1'
// ์คํ๋ง ๋ถํธ๋ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ด์ฅ ํฐ์บฃ์ ๊ฐ์ง๊ณ ์์ง๋ง
// jsp ์์ง์ด ์กด์ฌํ์ง ์์, jasper ์ jstl ์์กด์ฑ์ ์ถ๊ฐํด์ฃผ์ด์ผ ํ๋ค.
// jstl
implementation group: 'javax.servlet', name: 'jstl', version: '1.2'
// jasper
implementation group: 'org.apache.tomcat', name: 'tomcat-jasper', version: '9.0.56'
}
test {
useJUnitPlatform()
}
- application.yml ์ค์
spring:
application:
name: springboot-docker-sample
# DB Connection ( localhost:5432 --> Docker Postgresql 5432 )
datasource:
hikari:
# connect to host port
#jdbc-url: jdbc:log4jdbc:postgresql://localhost:5432/test
# connect to container port
jdbc-url: jdbc:log4jdbc:postgresql://Postgresql/test
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
username: test
password: test
maximum-pool-size: 5
# mvc config
# ๋ทฐ ๊ฒฝ๋ก ์ง์ ๋ฐ ํ์ฅ์ ์ค์
# jar ํ์ผ๋ก ์์ถํ๋ ๊ฒฝ์ฐ, jsp ์ง์ ์ํ๋ฏ๋ก ๊ธฐ๋ณธ ๊ฒฝ๋ก๊ฐ
# META-INF/resources/WEB-INF/view ๊ฐ ๋๋ค.
# develop ํ์ ...
mvc:
view:
prefix: /WEB-INF/views/
suffix: .jsp
# devtool config
# ์ ์ ๋ฆฌ์์ค ์์ ์๋ ์ฌ์์ ์์ด ๋ณ๊ฒฝ์ฌํญ ์ ์ฉ
devtools:
livereload:
enabled: true
** ๋์ผ docker network ์์ ์ปจํ ์ด๋๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ ์ปจํ ์ด๋์ Name ๊ฐ์ด {ip}:{port} ๊ฐ๊ณผ ๋์น๋์ด ์ฌ์ฉ์ด ๊ฐ๋ฅํ๋ค.
- ํ๋ก์ ํธ ๊ตฌ์กฐ
Docker Network ์์ฑ
docker create network boot-sample-network
์ต์ข Docker ์ด๋ฏธ์ง ์คํ ๋ช ๋ น
- postgresql ( M1 MAC ์์๋ " ๋ฅผ ' ๋ก ๋ณ๊ฒฝ )
docker run -d -p 5432:5432 -e POSTGRES_PASSWORD="{password}" -v postgresql-sample:/var/lib/postgresql/data --network boot-sample-network --name Postgresql postgres:12.9-alpine
- spring boot
docker run -d -p 8080:8080 --network boot-sample-network --name Boot-Sample boot-sample
- postgresql volume file
\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes ์ ์์ถํด์ . (์๋์ฐ๋ง)
* M1 Mac์์๋ ์ง์ ๊ฒฝ๋ก๋ก ๋ฃ๋ ๋ถ๋ถ์ ์ฐพ์ง ๋ชปํด ๊ทธ๋ฅ ๋ค์ ๋ง๋ค์๋ค ...
* ๊ฐ ์ด๋ฏธ์ง๋ dklim93/<image-name> ์ผ๋ก ๋ฐ์ ์ ์์.
์ฐธ๊ณ
- postgresql yml ์ค์
https://csy7792.tistory.com/292
[Spring] PostgreSQL yml ์ค์
spring boot PostgreSQL yml ์ค์ ์ ๋๋ค. spring: datasource: driver-class-name: org.postgresql.Driver url: jdbc:postgresql://url:port/database username: id password: password
csy7792.tistory.com
- ์ ์ ์์ค ์ฌ์์ ์์ด ๊ตฌ๋
https://suzxc2468.tistory.com/186
์คํ๋ง๋ถํธ(SpringBoot)์์ ์ฌ์์ ์์ด ์ ์ ์์ค(html, js, css) ๋ณ๊ฒฝ ์ ์ฉํ๊ธฐ
๋ณดํต ์นํ๋ก์ ํธ๋ฅผ ์ด๋๊ฐ์์ ๋ด๋ ค๋ฐ๋ , ๊ณผ๊ฑฐ์ ๋ณธ์ธ์ด ์ด๋ค ์ค์ ์ ํ๋ ๋น์ฐ ์ ํ๊ฒ ์ ์ ์์ค๋ฅผ ๋ณ๊ฒฝํ๊ณ ๋ธ๋ผ์ฐ์ ๋ฅผ ์๋ก๊ณ ์นจํ๋ฉด ๋ฐ์๋์๋ค. ๊ทธ๋ฌ๋ SpringBoot ํ๋ก์ ํธ๋ฅผ ์๋ก๋ง๋ค๊ณ ์
suzxc2468.tistory.com
- web xml ์ค์ ์ฌ์ฉ
https://oingdaddy.tistory.com/356
Springboot ํ๊ฒฝ์์ web.xml ์ jsp-config ์ฌ์ฉํ๊ธฐ (w.SpringBootServletInitializer)
์ผ์ ์ ๋๊ฐ์ ์ฃผ์ ์ ๋ํด ๊ธ์ ์ผ์๋๋ฐ ๋ ๊ด์ฐฎ์ ๋ฐฉ๋ฒ์ด ์์ด์ ๋ค์ ๊ธ์ ์์ฑํด๋ณธ๋ค. ์ ์ฉ๋ฐฉ๋ฒ์ ์์ฃผ ๊ฐ๋จํ๋ค. web.xml <?xml version="1.0" encoding="UTF-8"?> *.jsp UTF-8 false /WEB-INF/jsp/common/c..
oingdaddy.tistory.com
- docker Network ๊ณต์
[Docker] Docker Network๋ฅผ ์ด์ฉํ์ฌ ๋คํธ์ํฌ ๊ณต์ ํ๊ธฐ
Docker Network๋ ์คํ๋ ๊ฐ๊ฐ์ ์ปจํ ์ด๋๋ผ๋ฆฌ ์ฐ๊ฒฐํ๊ธฐ ์ํ ๋ ผ๋ฆฌ์ ์ธ ๋คํธ์ํฌ์ ๋๋ค. ๊ฐ์ ๋คํธ์ํฌ ์์์๋ ๊ฐ๊ฐ์ ์ปจํ ์ด๋์ IP๋ฅผ ์ง์ ํด์ฃผ๊ฑฐ๋ ํ ํ์ ์์ด name๋ง์ผ๋ก ์์ฝ๊ฒ ๋คํธ์ํฌ๋ฅผ
ooeunz.tistory.com
- docker Network ์ค์
https://docs.docker.com/engine/reference/commandline/network_connect/
docker network connect
docker network connect: Connects a container to a network. You can connect a container by name or by ID. Once connected, the container can communicate with other containers in the...
docs.docker.com
- ๋ฆฌ์์ค ๊ฒฝ๋ก ์ค์ ๊ด๋ จ
https://atoz-develop.tistory.com/entry/spring-boot-web-mvc-static-resources
[์คํ๋ง ๋ถํธ/MVC] ์ ์ ๋ฆฌ์์ค(Static Resources) ๊ธฐ๋ณธ ์ค์ ๊ณผ ์ปค์คํ ๋ฐฉ๋ฒ
[์คํ๋ง ๋ถํธ/MVC] ์ ์ ๋ฆฌ์์ค(Static Resources) ๊ธฐ๋ณธ ์ค์ ๊ณผ ์ปค์คํ ๋ฐฉ๋ฒ ์คํ๋ง ๋ถํธ๋ ์ ์ ๋ฆฌ์์ค(static resources)์ ๋ํ ๊ธฐ๋ณธ ๋งคํ ์ค์ ๊ณผ ์ปค์คํ ์ ์ง์ํ๋ค. ์ค์ ๋ก ํ์ธํด๋ณด์. ์คํ๋ง ๋ถ
atoz-develop.tistory.com
https://stackoverflow.com/questions/28725635/spring-boot-configure-it-to-find-the-webapp-folder
Spring boot: configure it to find the webapp folder
By default, Spring Boot looks in my src/main/webapp folder to find my html files. Where can I change the settings for Spring Boot if I use another folder to put the html files? Later, the files wi...
stackoverflow.com
- docker volume ์๋์ฐ ๊ฒฝ๋ก
\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes
๊ฐ์ ์ฌํญ
- ๋ฐ์ดํฐ ๊ณต์ ๋ volume ํํ๊ฐ ์๋ ํ์ผ(๋๋ ํ ๋ฆฌ) ๊ณต์ ํํ๋ก ๋ณ๊ฒฝ > ์ฝ๊ฒ ์ฎ๊ธธ ์ ์๋ค.
- ์คํ๋ง jsp ๋ฆฌ์์ค ๊ฒฝ๋ก๋ ๋ฐฉ๋ฒ์ ํตํด ๋ณต์กํ์ง ์์ ๊ฒฝ๋ก๋ก ๋ณ๊ฒฝํ ๊ฒ.
'๐Docker' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Docker CentOS7] CentOS7 locale language ko_KR ์ค์ (0) | 2022.06.23 |
---|---|
[์ค์ต] Docker Spring Boot + Postgresql (3) (0) | 2022.01.25 |
[์ค์ต] Docker Spring Boot + Postgresql (2) (0) | 2022.01.24 |
MS : Docker ์์ต์ ์ ๋ฆฌ (0) | 2022.01.13 |
[MS ์์ต์] Docker Application build Python ์๋ฌ ํด๊ฒฐ (2) | 2022.01.10 |
๋๊ธ