Docker : Tomcat 설치

카테고리 없음 2022. 1. 13. 00:48 Posted by 파란크리스마스

출처

도커이미지 다운로드

bluesanta@Kubuntu:~$ sudo docker pull tomcat:8
8: Pulling from library/tomcat
0e29546d541c: Pull complete 
9b829c73b52b: Pull complete 
cb5b7ae36172: Pull complete 
6494e4811622: Pull complete 
668f6fcc5fa5: Pull complete 
dc120c3e0290: Pull complete 
8f7c0eebb7b1: Pull complete 
77b694f83996: Pull complete 
b7c26350ecc2: Pull complete 
7365b3b02e1b: Pull complete 
Digest: sha256:421c2a2c73f3e339c787beaacde0f7bbc30bba957ec653d41a77d08144c6a028
Status: Downloaded newer image for tomcat:8
docker.io/library/tomcat:8

다운로드 받은 도커이미지 목록 조회

bluesanta@Kubuntu:~$ sudo docker images
REPOSITORY            TAG       IMAGE ID       CREATED        SIZE
tomcat                8         2d2bccf89f53   2 weeks ago    678MB
portainer/portainer   latest    580c0e4e98b0   9 months ago   79.1MB

컨테이너 생성

bluesanta@Kubuntu:~$ sudo docker run -d --name tomcat8 --network host tomcat:8
cf03b6241ff2db6fcb90250358a1ac8a17443c1c20cac3f73905165f4cc28c44

도커에 iv 편집기 설치

컨테이너 bash 접속

bluesanta@Kubuntu:~$ sudo docker exec -it tomcat8 bash
root@Kubuntu:/usr/local/tomcat#

apt-get 업데이트

root@Kubuntu:/usr/local/tomcat# apt-get update

vim install

root@Kubuntu:/usr/local/tomcat# apt install vim

tomcat 포트 변경(8080 -> 9090)

환경파일 수정 (server.xml)

root@Kubuntu:/usr/local/tomcat# vi /usr/local/tomcat/conf/server.xml

server.xml

    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

Tomcat 재실행

Tomcat이 서비스로 실행되어 있는 것이 아나라서 docker 컨테이너를 재실행해야됨

bluesanta@Kubuntu:~$ sudo docker restart tomcat8
tomcat8

Host 모드로 실행 확인

프로세스 확인

Host 모드로 실행되어 ps 명령으로 확인 가능

bluesanta@Kubuntu:~$ ps -ef | grep java
root       80711   80680  3 14:36 ?        00:00:06 /usr/local/openjdk-11/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
bluesan+   80877   80393  0 14:39 pts/0    00:00:00 grep --color=auto java
 
bluesanta@Kubuntu:~$ /usr/local/openjdk-11/bin/java --version
-bash: /usr/local/openjdk-11/bin/java: 그런 파일이나 디렉터리가 없습니다
 
bluesanta@Kubuntu:~$ sudo docker exec -it tomcat8 bash
root@Kubuntu:/usr/local/tomcat# /usr/local/openjdk-11/bin/java --version
openjdk 11.0.13 2021-10-19
OpenJDK Runtime Environment 18.9 (build 11.0.13+8)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8, mixed mode, sharing)

포트 확인

bluesanta@Kubuntu:~$ netstat -nao | grep 9090
tcp6       0      0 :::9090                 :::*                    LISTEN      off (0.00/0/0)

댓글을 달아 주세요