본문 바로가기

회고록(TIL&WIL)

TIL 2023.03.03 docker tomcat 배포

docker

docker-machine ssh default   
docker -v    
-a 전부 확인   
-h 설명서 (안되면 --help)   
docker pull hello-world   
docker image ls   
docker container create hello-world   
docker container ls -a   
docker container start NAME|ID   
docker container rm NAME|ID   
docker image rm hello-world    

-- getting-started
docker image pull docker/getting-started   
docker container create docker/getting-started   
docker container start NAME|ID   
docker container ls   
docker exec -it 0d6f /bin/sh (container의 linux로 접속)   
curl http://localhost:80/    
exit   
docker container stop ID  
docker container rm ID     
docker images (=image ls)   
docker run -it -d -p 8080:80 3e   
curl http://localhost:8080   
curl http://192.168.99.100:8080(docker 시작시 출력된 ip)
docker container rm -f ID ID ID ...

-- mysql
docker pull mysql
docker container create -it -p 3306:3306 -p 8080:8080 -e MYSQL_ROOT_PASSWORD=my-secret-pw 4f06
docker container start ID
exit
mysql -h 192.168.99.100 -u root -pmy-secret-pw

-- ubuntu
docker pull ubuntu:20.04
docker container create -p 8888:8080 -p 8080:80 -p 3306:3306 -it 61c45 /bin/bash
docker container start ID
docker exec -it ID /bin/bash
apt update
apt install -y openjdk-8-jdk-headless
apt install -y maven
apt install -y wget
apt install -y curl
apt install -y nano
apt install -y git
wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.86/bin/apache-tomcat-8.5.86.tar.gz
tar -zxvf apache-tomcat-8.5.86.tar.gz
cd ~
mv apache-tomcat-8.5.86 tomcat1
cd tomcat1/bin
./startup.sh
외부 localhost8888로 접근 가능
cd ~
tar -zxvf apache-tomcat-8.5.86.tar.gz
mv apache-tomcat-8.5.86 tomcat2
cd tomcat2/conf
nano server.xml
port번호 변경 8080 > 80 / 8443> 8843 
cd tomcat2/bin
./startup.sh
외부 localhost:8080으로 접근 가능
apt install -y mysql-server-8.0
service mysql start
mysql -u root
alter user 'root'@'localhost' identified with mysql_native_password by 'mysql';
create user 'root'@'%' identified with mysql_native_password by 'mysql';
create user 'scott'@'%' identified with mysql_native_password by 'tiger';
grant all privileges on *.* to 'scott'@'%';
alter user 'root'@'%' identified by 'mysql';
alter user 'scott'@'%' identified by 'tiger';
flush privileges;
nano /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address 부분 주석처리하기 (# 달기)
service mysql start
외부에서 mysql -h 192.168.99.100 -u scott -ptiger 로 접속 가능

git clone url
mvn package -Dmaven.test.skip=true

docker container commit -m "test" d114 test2:v1