<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.2">Jekyll</generator><link href="https://bryce0516.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://bryce0516.github.io/" rel="alternate" type="text/html" /><updated>2022-12-06T06:21:58+00:00</updated><id>https://bryce0516.github.io/feed.xml</id><title type="html">MM</title><subtitle>Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.</subtitle><author><name>First Lastname</name></author><entry><title type="html">Post: nginx</title><link href="https://bryce0516.github.io/nginx/aws-error/" rel="alternate" type="text/html" title="Post: nginx" /><published>2022-04-14T00:00:00+00:00</published><updated>2022-04-13T21:20:02+00:00</updated><id>https://bryce0516.github.io/nginx/aws%20error</id><content type="html" xml:base="https://bryce0516.github.io/nginx/aws-error/">&lt;h1 id=&quot;aws-npm-install-시-ec2micro-뻗어버리는-현상&quot;&gt;aws npm install 시 ec2.micro 뻗어버리는 현상&lt;/h1&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; npm cache clean --force =&amp;gt; 캐시제거
 npm install --verbose =&amp;gt; 현재상황 파악

 여전히 오류 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h1 id=&quot;임시방편으로-스왑-공간-계산후-스왑파일-생성하는-방법&quot;&gt;임시방편으로 스왑 공간 계산후 스왑파일 생성하는 방법&lt;/h1&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
메모리 체크  free -m 

1.    dd 명령을 사용하여 루트 파일 시스템에 스왑 파일을 생성합니다. 명령에서 bs는 블록 크기이고 count는 블록 수입니다. 스왑 파일의 크기는 dd 명령의 블록 크기 옵션에 블록 수 옵션을 곱한 값입니다. 이러한 값을 조정하여 원하는 스왑 파일 크기를 결정합니다.

지정한 블록 크기는 인스턴스에서 사용 가능한 메모리보다 작아야 합니다. 그렇지 않으면 &quot;memory exhausted&quot; 오류가 발생합니다.

이 예제 dd 명령에서 스왑 파일은 4GB(128MB x 32)입니다.

$ sudo dd if=/dev/zero of=/swapfile bs=128M count=32
2.    스왑 파일의 읽기 및 쓰기 권한을 업데이트합니다.

$ sudo chmod 600 /swapfile
3.    Linux 스왑 영역을 설정합니다.

$ sudo mkswap /swapfile
4.    스왑 공간에 스왑 파일을 추가하여 스왑 파일을 즉시 사용할 수 있도록 합니다.

$ sudo swapon /swapfile
5.    프로시저가 성공적인지 확인합니다.

$ sudo swapon -s
6.    /etc/fstab 파일을 편집하여 부팅 시 스왑 파일을 시작합니다.

편집기에서 파일을 엽니다.

$ sudo vi /etc/fstab
파일 끝에 다음 줄을 새로 추가하고 파일을 저장한 다음 종료합니다.

/swapfile swap swap defaults 0 0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>First Lastname</name></author><category term="nginx" /><summary type="html">aws npm install 시 ec2.micro 뻗어버리는 현상</summary></entry><entry><title type="html">Post: nginx</title><link href="https://bryce0516.github.io/nginx/nginx-config/" rel="alternate" type="text/html" title="Post: nginx" /><published>2022-04-13T00:00:00+00:00</published><updated>2022-04-13T21:20:02+00:00</updated><id>https://bryce0516.github.io/nginx/nginx%20config</id><content type="html" xml:base="https://bryce0516.github.io/nginx/nginx-config/">&lt;h1 id=&quot;nginx-config&quot;&gt;nginx config&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;conf.d
server {
        listen 0.0.0.0:80;
        server_name _;
        location / {
                root /usr/share/nginx/html/images;
        }
 
        location /api {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_set_header X-NginX-Proxy true;

                proxy_pass http://localhost:3100;
                proxy_redirect off;
        }
        location /profile {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_set_header X-NginX-Proxy true;

                proxy_pass http://localhost:3000;
                proxy_redirect off;
        }
        location /images {
                alias /usr/share/nginx/html/images/;
        }

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] &quot;$request&quot; '
                      '$status $body_bytes_sent &quot;$http_referer&quot; '
                      '&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
  
    
    proxy_cache_path /var/cache/nginx/images/ levels=1:2 keys_zone=cache_zone:40m inactive=7d max_size=100m;
    proxy_temp_path /var/cache/nginx/temp/;
    proxy_cache_key &quot;$scheme$request_method$host$request_uri&quot;;
 
    include /etc/nginx/conf.d/*.conf;
   
     server {
        listen       80;
        listen       [::]:80;
        server_name  _;
        # root         /usr/share/nginx/html;
        # root /usr/share/nginx/html/images;             
        access_log on;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2;
#        listen       [::]:443 ssl http2;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate &quot;/etc/pki/nginx/server.crt&quot;;
#        ssl_certificate_key &quot;/etc/pki/nginx/private/server.key&quot;;
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers PROFILE=SYSTEM;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>First Lastname</name></author><category term="nginx" /><summary type="html">nginx config ``` conf.d server { listen 0.0.0.0:80; server_name _; location / { root /usr/share/nginx/html/images; } location /api { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true;</summary></entry><entry><title type="html">Post: Docker3 -docker swarm</title><link href="https://bryce0516.github.io/blog/docker4/" rel="alternate" type="text/html" title="Post: Docker3 -docker swarm" /><published>2022-03-24T00:00:00+00:00</published><updated>2022-03-23T21:20:02+00:00</updated><id>https://bryce0516.github.io/blog/docker4</id><content type="html" xml:base="https://bryce0516.github.io/blog/docker4/">&lt;h1 id=&quot;docker-swarm&quot;&gt;docker-swarm&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  * docker info 
  - looking for swram in docker info list
  
  inactive 면

  docker swram init
  - 이때 토큰이 발생한다 join token 다른(떨어진 물리적으로) 인스턴스에 설치하여 합류가능
  docker swarm join --token &amp;lt; contents &amp;gt;
   -- 합류한 인스턴스 역할 변경
   docker node update --role manager or worker node 2
  - 토큰 발생시키기
  docker swarm join-token manager or worker
  -- 목록조회 
  docker node ls

  
  * create service
  docker create service &amp;lt;image&amp;gt; &amp;lt;ping&amp;gt; port
  docker service ps &amp;lt;serviceId&amp;gt;
  - 서비스확인
  docker service ps 
  - 클러스터 3개로 돌리기 (docker container rm을 하여도 자동으로 다시 돌린다.)
  docker service update &amp;lt;serviceId&amp;gt; --replicas 3
  - 도커 네트워크 생성
  docker network create --driver overlay mydrupal
  - 도커 서비스 생성 sql network 환경 이미지이름
  docker service create --name psql --network mydrupal -e POSTGRES_PASSWORD=123 postgres
  - example 
  docker service create --name drupal --network mydrupal -p 80:80 drupal
  docker service create --name search --replicas 3 -p 9200:9200 elasticsearch:2
  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>First Lastname</name></author><category term="Blog" /><category term="Docker" /><category term="Docker Swarm" /><summary type="html">docker-swarm ``` docker info looking for swram in docker info list inactive 면</summary></entry><entry><title type="html">linux</title><link href="https://bryce0516.github.io/blog/LINUX/" rel="alternate" type="text/html" title="linux" /><published>2022-03-23T00:00:00+00:00</published><updated>2022-03-23T21:20:02+00:00</updated><id>https://bryce0516.github.io/blog/LINUX</id><content type="html" xml:base="https://bryce0516.github.io/blog/LINUX/">&lt;h1 id=&quot;linux-유용한-명령어-모음&quot;&gt;linux 유용한 명령어 모음&lt;/h1&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  * shell 확인
   - echo $SHELL  
  * alias 지정
   - alias  #list
   - ~/.bashrc #vi/vim  후 source
   - alias dd=''  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>First Lastname</name></author><category term="Blog" /><category term="linux" /><summary type="html">linux 유용한 명령어 모음</summary></entry><entry><title type="html">Post: Docker3 -docker compose</title><link href="https://bryce0516.github.io/blog/docker3/" rel="alternate" type="text/html" title="Post: Docker3 -docker compose" /><published>2022-03-23T00:00:00+00:00</published><updated>2022-03-23T21:20:02+00:00</updated><id>https://bryce0516.github.io/blog/docker3</id><content type="html" xml:base="https://bryce0516.github.io/blog/docker3/">&lt;h1 id=&quot;docker-compose&quot;&gt;docker-compose&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; * configure relationships between containers
 * save our docker container run settings in easy to read file
 * create one-liner developer environment startups
 * comprised of 2 separate but related things
 * using yaml 
  - containers
  - networks
  - volumes
 *
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;docker-composeyaml&quot;&gt;docker-compose.yaml&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  version: '3.1'  # if no version is specified then v1 is assumed. Recommend v2 minimum

  services:  # containers. same as docker run
    servicename: # a friendly name. this is also DNS name inside network
      image: # Optional if you use build:
      command: # Optional, replace the default CMD specified by the image
      environment: # Optional, same as -e in docker run
      volumes: # Optional, same as -v in docker run
    servicename2:

  volumes: # Optional, same as docker volume create

  networks: # Optional, same as docker network create
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  ////////////// example
  version: '2'

  # same as 
  # docker run -p 80:4000 -v $(pwd):/site bretfisher/jekyll-serve

  services:
    jekyll:
      image: bretfisher/jekyll-serve
      volumes:
        - .:/site
      ports:
        - '80:4000'


&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  ////////////// example2
  version: '2'
  services:

    wordpress:
      image: wordpress
      ports:
        - 8080:80
      environment:
        WORDPRESS_DB_HOST: mysql
        WORDPRESS_DB_NAME: wordpress
        WORDPRESS_DB_USER: example
        WORDPRESS_DB_PASSWORD: examplePW
      volumes:
        - ./wordpress-data:/var/www/html

    mysql:
      # we sue mariadb here for arm support
      # mariadb is a fork of MySQL that's often faster and better multi-platform
      image: mariadb
      environment:
        MYSQL_ROOT_PASSWORD: examplerootPW
        MYSQL_DATABASE: wordpress
        MYSQL_USER: example
        MYSQL_PASSWORD: examplePW
      volumes:
        - mysql-data:/var/lib/mysql

  volumes:
    mysql-data:
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  ////////////// example3
  version: '3'
# NOTE: This example only works on x86_64 (amd64)
# Percona doesn't yet publish arm64 (Apple Silicon M1) or arm/v7 (Raspberry Pi 32-bit) images

services:
  ghost:
    image: ghost // webserver
    ports:
      - &quot;80:2368&quot;
    environment:
      - URL=http://localhost
      - NODE_ENV=production
      - MYSQL_HOST=mysql-primary
      - MYSQL_PASSWORD=mypass
      - MYSQL_DATABASE=ghost
    volumes:
      - ./config.js:/var/lib/ghost/config.js
    depends_on:
      - mysql-primary
      - mysql-secondary
  proxysql:
    # image only works on x86_64 (amd64)
    image: percona/proxysql
    environment:
      - CLUSTER_NAME=mycluster
      - CLUSTER_JOIN=mysql-primary,mysql-secondary
      - MYSQL_ROOT_PASSWORD=mypass

      - MYSQL_PROXY_USER=proxyuser
      - MYSQL_PROXY_PASSWORD=s3cret
  mysql-primary:
    # image only works on x86_64 (amd64)
    image: percona/percona-xtradb-cluster:5.7
    environment:
      - CLUSTER_NAME=mycluster
      - MYSQL_ROOT_PASSWORD=mypass
      - MYSQL_DATABASE=ghost
      - MYSQL_PROXY_USER=proxyuser
      - MYSQL_PROXY_PASSWORD=s3cret
  mysql-secondary:
    # image only works on x86_64 (amd64)
    image: percona/percona-xtradb-cluster:5.7
    environment:
      - CLUSTER_NAME=mycluster
      - MYSQL_ROOT_PASSWORD=mypass

      - CLUSTER_JOIN=mysql-primary
      - MYSQL_PROXY_USER=proxyuser
      - MYSQL_PROXY_PASSWORD=s3cret
    depends_on:
      - mysql-primary

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;docker-compose-cli&quot;&gt;docker compose cli&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;* most common use
- docker-compose up # setup volumes/networks and start all containers
- docker-compose donw # stop all containers and remove container/volume/network
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  * example 
  version: '3'

  services:
    proxy:
      image: nginx:1.13 # this will use the latest version of 1.13.x
      ports:
        - '80:80' # expose 80 on host and sent to 80 in container
      volumes:
        - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro #ro is readonly
    web:
      image: httpd  # this will use httpd:latest
  -----
  here is example 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>First Lastname</name></author><category term="Blog" /><category term="Docker" /><category term="Docker Compose" /><summary type="html">docker-compose * configure relationships between containers * save our docker container run settings in easy to read file * create one-liner developer environment startups * comprised of 2 separate but related things * using yaml - containers - networks - volumes *</summary></entry><entry><title type="html">Post: Docker2</title><link href="https://bryce0516.github.io/blog/docker2/" rel="alternate" type="text/html" title="Post: Docker2" /><published>2022-03-22T00:00:00+00:00</published><updated>2022-03-22T21:20:02+00:00</updated><id>https://bryce0516.github.io/blog/docker2</id><content type="html" xml:base="https://bryce0516.github.io/blog/docker2/">&lt;h1 id=&quot;docker-doc&quot;&gt;docker-doc&lt;/h1&gt;

&lt;h1 id=&quot;docker-image-command&quot;&gt;docker image command&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;// 도커 이미지 정보 
docker image inspect &amp;lt;imageName&amp;gt;


// 도커 이미지 태그정보 변경
docker image tag &amp;lt;imageName&amp;gt; &amp;lt;wantedName like dole/nginx&amp;gt;

// 태그정보 변경된 이름으로 푸쉬
docker image push &amp;lt;targetName&amp;gt;

// 도커 로그인/로그아웃
docker login/logout

// 로그인 정보확인
cat .docker/config.json
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;docker-build-dockerfile&quot;&gt;docker build dockerfile&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;// 도커파일 빌드

docker image build -t customnginx .
-&amp;gt; docker image build -target &amp;lt;wantedName&amp;gt; &amp;lt;. = currentfolder&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;about-dockerfile&quot;&gt;About dockerfile&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  FROM : Docker Base Image (기반이 되는 이미지, &amp;lt;이미지 이름&amp;gt;:&amp;lt;태그&amp;gt; 형식으로 설정)
  MAINTAINER : 메인테이너 정보 (작성자 정보)
  RUN : Shell Script 또는 명령을 실행
  CMD : 컨테이너가 실행되었을 때 명령이 실행
  LABEL : 라벨 작성 (docker inspect 명령으로 label 확인할 수 있습니다.)
  EXPOSE : 호스트와 연결할 포트 번호를 설정한다.
  ENV : 환경변수 설정
  ADD : 파일 / 디렉터리 추가
  COPY : 파일 복사
  ENTRYPOINT : 컨테이너가 시작되었을 때 스크립트 실행
  VOLUME : 볼륨 마운트
  USER : 명령 실행할 사용자 권한 지정
  WORKDIR : &quot;RUN&quot;, &quot;CMD&quot;, &quot;ENTRYPOINT&quot; 명령이 실행될 작업 디렉터리
  ARG : Dockerfile 내부 변수
  ONBUILD : 다른 이미지의 Base Image로 쓰이는 경우 실행될 명령 수행
  SHELL : Default Shell 지정
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;dockerfile-run&quot;&gt;dockerfile run&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Dockerfile
  FROM node:6-alpine
  EXPOSE xxxx
  RUN apk add --update tini
  RUN mkdir -p /usr/src/app 
  WORKDIR /usr/src/app
  COPY package.json package.json
  RUN npm install &amp;amp;&amp;amp; npm cache clean --force
  COPY . .
  CMD [ &quot;tini&quot;, &quot;--&quot;, &quot;node&quot;, &quot;./bin/www&quot;]


docker build -t mynode .
docker container run --rm -p 80:3000 mynode
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;도커에서-포트-의미--내포트컨테이너포트&quot;&gt;도커에서 포트 의미 =&amp;gt; 내포트:컨테이너포트&lt;/h1&gt;

&lt;h1 id=&quot;prune&quot;&gt;prune&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; -- 사용하지않는 이미지 삭제
 docker image prune

 -- 사용하지 않는 컨테이너 삭제
 docker container prune

 -- 사용하지 않는 볼륨 삭제
 docker container prune
 
 -- 사용하지 않는 네트워크 삭제
 docker container prune

 -- 사용하지 않는 docker object삭제
 docker system prune
 

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;도커-볼륨-확인&quot;&gt;도커 볼륨 확인&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;-- 도커에서 mysql 등 persistent data 등은 볼륨에서 확인할 수 있는데
docker contianer inspect &amp;lt;container&amp;gt; 시 마운트에서 정보를 확인 할 수 있다.
        &quot;Mounts&quot;: [
            {
                &quot;Type&quot;: &quot;volume&quot;,
                &quot;Name&quot;: &quot;a524a4a94f434b7f9e2edc355aff1941b261bd782e525dbb7c08751d9040b461&quot;,
                &quot;Source&quot;: &quot;/var/lib/docker/volumes/a524a4a94f434b7f9e2edc355aff1941b261bd782e525dbb7c08751d9040b461/_data&quot;,
                &quot;Destination&quot;: &quot;/var/lib/mysql&quot;,
                &quot;Driver&quot;: &quot;local&quot;,
                &quot;Mode&quot;: &quot;&quot;,
                &quot;RW&quot;: true,
                &quot;Propagation&quot;: &quot;&quot;
            }
        ],

name으로 볼륨확인을 할 수 있는데
내 로컬 볼륨을 확인해보면
docker volume ls =&amp;gt; 
docker volume inspect &amp;lt;volume&amp;gt;
컨테이너 실행할때마다 영속성 데이터 볼륨은 생성되는데 정지해도 없어지지 않는다
docker container run -d --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=True -v mysql-db:/var/lib/mysql mysql
-v 명령어는 볼륨 지정 및 볼륨 네이밍을 할 수 있는데 이로 관리하는게 편함
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;도커-볼륨-생성&quot;&gt;도커 볼륨 생성&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker volume create &amp;lt;options&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;bind-mounting&quot;&gt;bind mounting&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;* 도커파일에서는 쓰면 안되고 container run 명령어로 써야함
                  ($pwd) or {$pwd}: container path
container run -v /usr/myfolder/directory:/conatinerpath/directory (mac/linux)

도커 이미지 생성한 폴더에서 폴더를 만들거나 파일을 만들면 컨테이너 패스에도 똑같이 나타남
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h1 id=&quot;rewriting-docker-bash-명령어&quot;&gt;rewriting docker bash 명령어&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker container exec -it &amp;lt;conatiner&amp;gt; bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>First Lastname</name></author><category term="Blog" /><category term="Docker" /><summary type="html">docker-doc</summary></entry><entry><title type="html">Post: Docker1</title><link href="https://bryce0516.github.io/blog/docker1/" rel="alternate" type="text/html" title="Post: Docker1" /><published>2022-03-21T00:00:00+00:00</published><updated>2022-03-22T21:20:02+00:00</updated><id>https://bryce0516.github.io/blog/docker1</id><content type="html" xml:base="https://bryce0516.github.io/blog/docker1/">&lt;h1 id=&quot;docker-doc&quot;&gt;docker-doc&lt;/h1&gt;

&lt;h1 id=&quot;ec2-용량-꽉찻을경우&quot;&gt;ec2 용량 꽉찻을경우&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;df -hT #각 볼륨의 파일시스템 용량, 타입 확인

du &amp;lt;dir&amp;gt; #


EBS 콘솔에서 내 볼륨 우클릭 후 수정해서 크기를 8에서 16으로 수정함.
lsblk 명령어로 인스턴스에 연결된 블록디바이스를 확인


sudo growpart &amp;lt;볼륨&amp;gt; &amp;lt;파티션번호&amp;gt;



sudo resize2fs &amp;lt;파티션&amp;gt;


권한이없을경우 권한부여
sudo chmod 666 /var/run/docker.sock

권한부여후 sudo usermod -a -G docker ec2-user


docker info
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;도커-아마존리눅스설치&quot;&gt;도커 아마존리눅스설치&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  sudo yum update -y
  sudo amazon-linux-extras install docker
  sudo service docker start
  sudo usermod -a -G docker ec2-user
  docker info
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h1 id=&quot;도커-이미지생성&quot;&gt;도커 이미지생성&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  touch Dockerfile
  
  RUN apt-get update &amp;amp;&amp;amp; \
 apt-get -y install apache2
  
  RUN echo 'Hello World!' &amp;gt; /var/www/html/index.html
  
  RUN echo '. /etc/apache2/envvars' &amp;gt; /root/run_apache.sh &amp;amp;&amp;amp; \
 echo 'mkdir -p /var/run/apache2' &amp;gt;&amp;gt; /root/run_apache.sh &amp;amp;&amp;amp; \
 echo 'mkdir -p /var/lock/apache2' &amp;gt;&amp;gt; /root/run_apache.sh &amp;amp;&amp;amp; \ 
 echo '/usr/sbin/apache2 -D FOREGROUND' &amp;gt;&amp;gt; /root/run_apache.sh &amp;amp;&amp;amp; \ 
 chmod 755 /root/run_apache.sh

EXPOSE 80

CMD /root/run_apache.sh
  
  dockerfile 에서 빌드
  docker build -t hello-world .
  
  이미지확인
  docker images --filter reference=hello-world
  
  docker run -t -i -p 80:80 hello-world
  
  
  docker-machine ip ~machine-name~
  
  
  # 자동시작도커
  sudo chkconfig docker on
  # 깃설치 반드시
  sudo yum install -y git 
  # 재부팅
  sudo reboot
  
  
  # docker compose install
  
Copy the appropriate docker-compose binary from GitHub:

sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

NOTE: to get the latest version (thanks @spodnet): sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

Fix permissions after download:

sudo chmod +x /usr/local/bin/docker-compose

Verify success:

docker-compose version
  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;# 도커 이미지 받아서 해당 포트에 프로세스 돌림 (–detach 백그라운드 / 없으면 바로 )&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  --detach 백그라운드 / 없으면 바로 
  --name 이름 설정
  docker container run --publish &amp;lt;port&amp;gt; &amp;lt;option&amp;gt; &amp;lt;image&amp;gt;
  docker container run --publish 8022:80 --detach nginx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;# 도커 컨테이너 리스트&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  docker container ls
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;# 도커 중지&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  docker container stop &amp;lt;container id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;# 도커 로그&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  name = 이미지 이름
  docker container logs &amp;lt;name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;# 프로세스에 올려진 도커 컨테이너 확인&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  name = 이미지 이름
  docker container top &amp;lt;name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;# 도커 리스트에서 이미지 삭제&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  running image는 삭제할수 없음
  -f 명령어 강제 종료
  docker container rm -f &amp;lt;container id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;# docker container run 동작원리&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  1. 로컬 이미지를 찾는다
  2. 도커허브에서 이미지 리모트를 한다
  3. 최신버전을 다운로드 받는다. (엔진엑스 최신버전)
  4. 컨테이너를만들고 시작함
  5. 가상 ip를 부여하고 docker engine을 올려둠
  6. 포트 번호에 할당
  7. image dockerfile 에있는 cmd실행
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;# 리눅스 프로세스 리스트&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  포트확인
  netstat -tnlp
  프로세스 확인
  ps aux
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;# docker container inspect - 컨테이너 설정 확인
  # docker container stats - 컨테이너 성능 확인&lt;/p&gt;

&lt;p&gt;# docker container exec &lt;image&gt; bash에서 ps -aux가 안먹히는경우&lt;br /&gt;&lt;/image&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;   apt-get update &amp;amp;&amp;amp; apt-get install procps
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;# docker container localshot ip inspect 로 확인하는방법&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  docker container inspect --format '' webhost
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;# docker container network 사용리스트&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  docker network ls
  docker network inspect bridge
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;# docker 버추얼 네트워크 변경&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  docker network ls 
  =&amp;gt; list id
  docker container ls
  =&amp;gt; list id 
  docker network connect &amp;lt;networkId&amp;gt; &amp;lt;containerId&amp;gt;
  
  --&amp;gt;docker container inspect &amp;lt;containerId&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;# docker 핑 체크&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  docker container exec -it &amp;lt;containerName&amp;gt; bash 
  apt-get update &amp;amp;&amp;amp; apt-get install -y iputils-ping
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>First Lastname</name></author><category term="Blog" /><category term="Docker" /><summary type="html">docker-doc</summary></entry><entry><title type="html">Xcode12frameworkdnotfound</title><link href="https://bryce0516.github.io/xcode12frameworkdnotfound/" rel="alternate" type="text/html" title="Xcode12frameworkdnotfound" /><published>2021-04-29T00:00:00+00:00</published><updated>2021-04-29T00:00:00+00:00</updated><id>https://bryce0516.github.io/xcode12frameworkdnotfound</id><content type="html" xml:base="https://bryce0516.github.io/xcode12frameworkdnotfound/">&lt;hr /&gt;
&lt;p&gt;title: “Framework Not Found with xcode 12 openssl etc”
date: 2021-04-29
categories:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;blog
tags:&lt;/li&gt;
  &lt;li&gt;ios&lt;/li&gt;
  &lt;li&gt;
    &lt;h2 id=&quot;react-native&quot;&gt;react-native&lt;/h2&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;To do that, navigate to Build Settings of your project and add Any iOS Simulator SDK with value arm64 inside Excluded Architecture.

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;일반적으로 user-define 설정을 따르지 않는경우 arm64를 excluded architecture.에 any ios simulator에 넣는다 넣고 cleanbuild 후 에뮬레이터를 돌린다.&lt;/p&gt;

&lt;p&gt;XCConfig 파일을 사용할 경우에는&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Pod project에&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' =&amp;gt; 'arm64' }
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' =&amp;gt; 'arm64' }

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;한후 pod install&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings[&quot;EXCLUDED_ARCHS[sdk=iphonesimulator*]&quot;] = &quot;arm64&quot;
  end
end



&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;참고 https://stackoverflow.com/questions/63607158/xcode-12-building-for-ios-simulator-but-linking-in-object-file-built-for-ios?page=1&amp;amp;tab=votes#tab-top&lt;/p&gt;</content><author><name>First Lastname</name></author><summary type="html">title: “Framework Not Found with xcode 12 openssl etc” date: 2021-04-29 categories: blog tags: ios react-native</summary></entry><entry><title type="html">First Post</title><link href="https://bryce0516.github.io/first-post/" rel="alternate" type="text/html" title="First Post" /><published>2021-03-02T00:00:00+00:00</published><updated>2021-03-02T00:00:00+00:00</updated><id>https://bryce0516.github.io/first-post</id><content type="html" xml:base="https://bryce0516.github.io/first-post/">&lt;hr /&gt;
&lt;p&gt;title: “Redux selector 관련”
date: 2021-03-02
categories:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;blog
tags:&lt;/li&gt;
  &lt;li&gt;redux&lt;/li&gt;
  &lt;li&gt;
    &lt;h2 id=&quot;selector&quot;&gt;selector&lt;/h2&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;const [friends, frends2] = useSelector(state =&amp;gt; [state.friend.friends, state.friend.friends2], shallowEqual)

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;friends, friends2의 레퍼런스만 비교하는 것이 아니고 각각을 비교하기 때문에 friends 만 렌더링이 된다.&lt;/p&gt;

&lt;p&gt;매번 shallowEqual을 쓰는 것은 불편하여 커스텀 훅을 만들어서 사용하길 권장&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;function useMyselector(selector) {
  return useSelector(selector, shallowEqual);
}

const [value, value2] = useMyselector(state =&amp;gt; [state.value1, state.value2]);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;이렇게 커스텀 훅을 사용할때는 모든 값을 비교하기 때문에 배열로 반환해주는 것이 좋다.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;const [value4] = useMyselector(state =&amp;gt; [state.value4])

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;상태값을 여러개 사용하는 또다른 방법은 reselect를 이용하는 방법이 있다.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import { createSelector } from 'reselect'

const getFriends = state =&amp;gt; state.friend.friends;
const getAgeLimit = state =&amp;gt; state.friend.ageLimit;
const getAgeShowLimit = state =&amp;gt; state.friend.showLimit;
export const getFriendWithAgeLimit  = createSelector(
  [ getFriends, getAgeLimit ],
  (friends, ageLimit) =&amp;gt; friends.filter(item =&amp;gt; item.age &amp;lt;= ageLimit),
)

export const getFriendWithAgeShowLimit  = createSelector(
  [ getFriendWithAgeLimit , geShowtAgeLimit ],
  ( friendsWithAgeLimit, showLimit ) =&amp;gt; friendsWithAgeLimit.slice(0, showLimit),
)

### 렌더링 부분

const [ 
  ageLimit,
  showLimit,
  friendsWithAgeLimit,
  friendsWithAgeShowLimit
] = useSelector(
  state =&amp;gt; [
    getAgeLimit(state),
    getShowLimit(state),
    getFriendsWithAgeLimit(state),
    getFriendsWithAgeShowLimit(state)
  ],
  shallowEqual,
)

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;이렇게 작성을하면 값으로 넘어오는 변수들이 변경되었을때만 실행을 하기때문에 메모이제이션 기능을 쓴다.&lt;/p&gt;</content><author><name>First Lastname</name></author><summary type="html">title: “Redux selector 관련” date: 2021-03-02 categories: blog tags: redux selector</summary></entry><entry><title type="html">jpa h2 connection</title><link href="https://bryce0516.github.io/blog/welcome-to-jekyll/" rel="alternate" type="text/html" title="jpa h2 connection" /><published>2019-04-18T19:34:30+00:00</published><updated>2019-04-18T19:34:30+00:00</updated><id>https://bryce0516.github.io/blog/welcome-to-jekyll</id><content type="html" xml:base="https://bryce0516.github.io/blog/welcome-to-jekyll/">&lt;h2 id=&quot;unable-to-login-into-h2-console&quot;&gt;Unable to login into H2 Console&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;Are you using &amp;gt;=2.3.0 Release of Spring Boot? You would need to configure this in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;application.properties&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;spring.datasource.url=jdbc:h2:mem:testdb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;Why is this needed? With the latest versions of Spring Boot (2.3+), the H2 database name is randomly generated each time you restart the server.  We do NOT want that. We want a constant URL.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:dd222195-7e0b-4dc0-ae4c-7f53e5ea7ceb'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;Make sure you are using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jdbc:h2:mem:testdb&lt;/code&gt; as the database URL in H2 Console as shown in the image below.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the browser, change the database url to jdbc:h2:mem:testdb (Shown in the screen below).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;images/h2-solution-image.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Do you have H2 dependency in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pom.xml&lt;/code&gt;? Try removing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;scope&amp;gt;runtime&amp;lt;/scope&amp;gt;&lt;/code&gt; and see if it makes a difference.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;
	&amp;lt;groupId&amp;gt;com.h2database&amp;lt;/groupId&amp;gt;
	&amp;lt;artifactId&amp;gt;h2&amp;lt;/artifactId&amp;gt;
&amp;lt;/dependency&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;Check if H2 Console is enabled in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;application.properties&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;spring.h2.console.enabled=true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;Delete your maven local repository (content of .m2 folder) and rebuild the project. (You are right. This looks silly. But do not skip it. I’ve seen many problems caused by dependency caches!)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;images/eclipse-maven-m2-folder.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;tables-are-not-created&quot;&gt;Tables are not created&lt;/h2&gt;

&lt;h3 id=&quot;are-you-using-spring-boot-250-release&quot;&gt;Are you using Spring Boot &amp;gt;=2.5.0 Release?&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Are you using &amp;gt;=2.5.0 Release of Spring Boot? You would need to configure this in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;application.properties&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;spring.jpa.defer-datasource-initialization=true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;OR you can use schema.sql instead of data.sql&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Why is this needed? https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.5.0-M3-Release-Notes#hibernate-and-datasql =&amp;gt; &lt;em&gt;By default, data.sql scripts are now run before Hibernate is initialized. This aligns the behaviour of basic script-based initialization with that of Flyway and Liquibase. If you want to use data.sql to populate a schema created by Hibernate, set spring.jpa.defer-datasource-initialization to true. While mixing database initialization technologies is not recommended, this will also allow you to use a schema.sql script to build upon a Hibernate-created schema before it’s populated via data.sql&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;no-1--are-you-using-spring-boot-230-release&quot;&gt;No 1 : Are you using Spring Boot &amp;gt;=2.3.0 Release?&lt;/h3&gt;

&lt;p&gt;Configure this in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;application.properties&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;spring.datasource.url=jdbc:h2:mem:testdb
spring.data.jpa.repositories.bootstrap-mode=default
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You should see this in the log&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:testdb'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;Why do we need to configure bootstrap-mode? Details here - https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#bootstrapmode-for-jpa-repositories&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;no-2--make-sure-you-have-the-right-annotations&quot;&gt;No 2 : Make sure you have the right annotations!&lt;/h3&gt;

&lt;p&gt;Make sure that the Entities have @Entity annotation and the Repository class has @Repository annotation&lt;/p&gt;

&lt;h3 id=&quot;no-3--make-sure-you-do-not-have-schemasql&quot;&gt;No 3 : Make sure you do NOT have schema.sql&lt;/h3&gt;

&lt;p&gt;Delete schema.sql if you have created one.&lt;/p&gt;

&lt;p&gt;If &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;schema.sql&lt;/code&gt; file exist, tables are NOT created.&lt;/p&gt;

&lt;h3 id=&quot;no-4--make-sure-your-component-is-picked-up-by-component-scan&quot;&gt;No 4 : Make sure your component is picked up by Component Scan&lt;/h3&gt;

&lt;p&gt;Spring Boot does a component scan in the package and sub-packages where your @SpringBootApplication is defined.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Why is this important? If your entity class or the repository class is NOT under the package of your @SpringBootApplication class, it will NOT be picked up by component scan.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;recommended-option---option-1--move-the-component-under-component-scan&quot;&gt;RECOMMENDED OPTION - Option 1 : Move the component under component scan&lt;/h4&gt;

&lt;p&gt;Simplest way to fix this is to identify the packages of the SpringBootApplication class and move all the components into that package or sub-packages of it.&lt;/p&gt;

&lt;h4 id=&quot;option-2--add-component-and-entity-scan-for-the-packages-containing-the-components&quot;&gt;Option 2 : Add component and entity scan for the packages containing the components&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;@SpringBootApplication(scanBasePackages= {&quot;com.project.currency.*&quot;})
@EntityScan(basePackages = {&quot;com.project.currency.model&quot;})
@EnableJpaRepositories(basePackages = {&quot;com.project.currency.repository&quot;})
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Learn more about component scan:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;https://github.com/in28minutes/in28minutes-initiatives/tree/master/The-in28Minutes-TroubleshootingGuide-And-FAQ#q—what-is-the-need-for-a-component-scan&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;230-course-update&quot;&gt;2.3.0 Course Update&lt;/h2&gt;

&lt;p&gt;With the latest versions of Spring Boot (2.3+), the H2 database name is randomly generated each time you restart the server.&lt;/p&gt;

&lt;p&gt;You can find the database name and URL from the console log.&lt;/p&gt;

&lt;h4 id=&quot;recommended&quot;&gt;RECOMMENDED:&lt;/h4&gt;

&lt;p&gt;Make the database URL a constant by configuring this in application.properties.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;spring.datasource.url=jdbc:h2:mem:testdb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;if-you-face-any-problems&quot;&gt;If you face any problems:&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Spring Boot 2.3.1 Upgrade - Changes&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;https://github.com/in28minutes/jpa-with-hibernate/commit/1f30e868ccd2eb7e69cdb989bc990cd00cc82168&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;JUnit 5 Upgrade - Changes&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;https://github.com/in28minutes/jpa-with-hibernate/commit/0ae2007c8e08420e6d5ab2a86499274c7c60c8ae&lt;/li&gt;
&lt;/ul&gt;</content><author><name>First Lastname</name></author><category term="blog" /><category term="Jekyll" /><category term="update" /><summary type="html">Unable to login into H2 Console</summary></entry></feed>