우선 docker로 mysql설치

docker run —name test-db -p 3306:3306 -e MYSQL_ROOT_PASSWORD=1234 -d mysql

컨테이너로 들어간후

mysql -uroot -p1234 mysql
create database people
use people
create table register(id int(3), name varchar(50),lastname varchar(50), aget int(3));

컨테이너를 나온다
이후 people.txt라는 파일을 만들고
내용은
Denice,Caule
Cherise,Olenick
~
~
이런식으로 50줄을 만든다

vi put.sh
#!/bin/bash

counter=0
while [ $counter -lt 50]; do
let counter=counter+1
name=$(nl people.txt |grep -w $counter| awk ‘{print $2}| awk -F ‘,’ ‘{print $1}’)

# nl은 파일 라인줄을 포함해서 출력해주고 grep -w 라인번호는 해당 라인번호 라인을 출력해준다, 첫번째 awk는 라인번호를 제외한 Denice,Caule이런식으로 출력을 해주며 두번째 awk는 -F를 기준으로 , 값으로 앞뒤를 구분해서 출력해준다 위의 name의 경우라면 앞의 값 Denice의 값을 가진다

lastname=$(nl people.txt|grep -w $counter| awk ‘{print $2}’|awk -F ‘,’ ‘{print $2}’)

age=$(shuf -i 20-25 -n 1)
# shuf는 램덤값을 출력하며 -i 는 범위를나타낸다 -n 은 출력라인을 몇개나 할것인지를 의미한다
20-25사이의 랜덤값을 하나씩 출력하라는 의미이다

mysql -uroot -p1234 people -e “insert into register values ($counter, ‘$name’,’$lastname’,$age)”

echo “$counter, $name $lastname, $age ws corrently imported”

done

docker cp put.sh test-db:/tmp and copy people.txt too
docker exec -it test-db bash

ls /tmp
./put.sh
db에 연결해서 테이블에 값이 정상적으로 들어갔는지 확인

nginx+php 설치

docker run -it -d —name nginx-test -p 8888:80 -v /home/nginx-test:/usr/share/nginx/html wyveo/nginx-php-fpm:latest

# php-fpm이 포함된 nginx이미지를 사용한다

vi info.php
<?php phpinfo(); ?>

웹주소:8888/info.php







'나는 노동자 > Jenkins' 카테고리의 다른 글

git clone username password  (0) 2019.12.18
gitlab 암호 잊어버렸을때  (0) 2019.11.13
Jenkins security login  (0) 2019.11.08
jenkins ansible output color  (0) 2019.11.05
jenkins root 추가  (0) 2019.11.04

+ Recent posts