Obsidian/Recognition/Programing/Docker/Docker 폐쇄망 설치.md

148 lines
3.2 KiB
Markdown
Raw Normal View History

2023-08-14 16:19:25 +00:00
#### 폐쇄망에서 도커 설치(tgz)
2024-03-29 08:36:47 +00:00
##### Docker 설치
```shell
# 도커 다운로드
https://download.docker.com/linux/static/stable/x86_64/
# 압축풀기
tar -xvf docker-20.10.21.tgz
2023-08-14 16:19:25 +00:00
2024-03-29 08:36:47 +00:00
# 소유자 변경
chown -R root:root docker
2023-08-14 16:19:25 +00:00
2024-03-29 08:36:47 +00:00
# bin폴더로 이동
mv docker/* /usr/bin/
2023-08-14 16:19:25 +00:00
2024-03-29 08:36:47 +00:00
# 도커 데몬 실행
dockerd &
```
##### Compose 설치
2023-08-14 16:19:25 +00:00
```bash
2024-03-29 08:36:47 +00:00
# docker-compose 파일 다운로드
# (https://github.com/docker/compose/releases)
2023-08-14 16:19:25 +00:00
2024-03-29 08:36:47 +00:00
cp docker-compose /usr/local/bin/docker-compose &&
chmod +x /usr/local/bin/docker-compose &&
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose &&
docker-compose --version
2023-08-14 16:19:25 +00:00
```
2024-03-08 09:25:42 +00:00
##### 일반 유저 도커 사용
```Shell
2023-08-14 16:19:25 +00:00
2024-03-08 09:25:42 +00:00
usermod -aG docker user_id
```
2023-08-14 16:19:25 +00:00
##### Daemon 설치 및 data-root 경로 변경
```bash
# 데몬 설치전 docker 컨테이너와 프로세스 모두 종료
# /var/lib/docker 폴더 삭제
2024-03-29 08:36:47 +00:00
# 도커용 로그 폴더 생성
# mkdir /home/gmt/{elk_data,Docker-data}
# 데몬 서비스 작성
2023-08-14 16:19:25 +00:00
nano /etc/systemd/system/docker.service
2024-03-29 08:36:47 +00:00
#########################################################
2023-12-23 14:26:28 +00:00
[Unit]
Description=Systemd Docker Daemon
[Service]
Type=simple
ExecStart=dockerd --data-root=/home/gmt/Docker-data
Restart=on-failure
[Install]
WantedBy=multi-user.target
2024-03-29 08:36:47 +00:00
#########################################################
2023-08-14 16:19:25 +00:00
2024-03-29 08:36:47 +00:00
# 도커 서비스 실행전 도커 데몬 프로세스 종료
ps -ef | grep docker
kill -9 [PID]
# 서비스 실행
systemctl daemon-reload &&
systemctl enable docker &&
systemctl start docker &&
2023-08-14 16:19:25 +00:00
systemctl status docker
2024-03-29 08:36:47 +00:00
```
##### 도커 이미지 로드
```bash
docker load -i /home/gmt/SACP-INSTALL/docimgs/docimg_cp-kafka.tar
# ELK 도커 이미지 로드
docker load -i /home/gmt/SACP-INSTALL/docimgs/docimg_elasticserch.tar
docker load -i /home/gmt/SACP-INSTALL/docimgs/docimg_kibana.tar
docker load -i /home/gmt/SACP-INSTALL/docimgs/docimg_logstash.tar
2023-08-14 16:19:25 +00:00
```
2024-03-29 08:36:47 +00:00
2023-08-14 16:19:25 +00:00
```
##### Compose 실행
1. docker-compose.yml 작성
2. docker-compose.yml 위치로 이동
3. 명령어 수행
```bash
docker-compose build && docker-compose up -d
cd /opt/SACP-INSTALL/docker-elk/
cd /opt/SACP-INSTALL/
docker exec -it kafka1 bash
## 테스트시 특정 컨테이너 및 이미지 일괄 삭제
docker rm -f logstash7 && docker rm -f es01 && docker rm -f kibana7
docker rm -f logstash7 && docker rm -f es02 && docker rm -f es03 && docker rm -f kibana7
docker rmi -f `docker images | awk '$1 ~ /elastic/ {print $3}'`
docker images
cd /opt/SACP-INSTALL/docker-elk/ && docker-compose build && docker-compose up -d
cd /opt/SACP-INSTALL/ && docker-compose build && docker-compose up -d
2023-12-23 14:26:28 +00:00
docker exec -it es01 bash
2023-08-14 16:19:25 +00:00
du -h --max-depth=1
cd /usr/share/elasticsearch/bin/
elasticsearch-certutil ca
find / -name "elastic-stack-ca.p12"
--> /usr/share/elasticsearch/elastic-stack-ca.p12
elasticsearch-certutil cert --ca elastic-stack-ca.p12
find / -name "elastic-certificates.p12"
--> /usr/share/elasticsearch/elastic-certificates.p12
```
###### CF.
https://velog.io/@ewan/%EC%9D%B8%ED%84%B0%EB%84%B7-%EC%97%86%EB%8A%94-%EC%84%9C%EB%B2%84%EC%97%90%EC%84%9C-Docker-%EC%84%A4%EC%B9%98%EB%A5%BC
https://projooni.tistory.com/entry/linux-1804-%EC%98%A4%ED%94%84%EB%9D%BC%EC%9D%B8-%ED%99%98%EA%B2%BD%EC%97%90%EC%84%9C-docker-%EB%B0%94%EC%9D%B4%EB%84%88%EB%A6%AC-%EC%84%A4%EC%B9%98