본문 바로가기

Micro Service Architecture/Docker

16. [docker] Portainer 설치

반응형

1. Docker swarm cluster 를 remote로 API를 통해 연결 하는 manager tool인 Portainer 서버 구축

2. Portainer는 컨테이너 기반이라 기본적으로 docker 가 설치 되어야 한다.

3. 설치

## Docker 설치
[root@Docker-Portainer ~]# curl -s https://get.docker.com | sudo sh
 
 
## iptables disable
[root@Docker-Portainer ~]# systemctl stop firewalld
[root@Docker-Portainer ~]# systemctl disable firewalld
 
## Docker start
[root@Docker-Portainer ~]# systemctl restart docker

 
## Portainer 설치
[root@Docker-Portainer ~]# docker run -d -p 9000:9000 --name=portainer \
> --restart=unless-stopped \
> -v /var/run/docker.sock:/var/run/docker.sock \
> -v /data/portainer/data:/data \
> portainer/portainer
Unable to find image 'portainer/portainer:latest' locally
latest: Pulling from portainer/portainer
d1e017099d17: Pull complete
717377b83d5c: Pull complete
Digest: sha256:f8c2b0a9ca640edf508a8a0830cf1963a1e0d2fd9936a64104b3f658e120b868
Status: Downloaded newer image for portainer/portainer:latest
243bbc9ccb8981a50f170c4f83a67c5e5730ccfb176c314d8b53e90e8ca9bd7a
 
[root@Docker-Portainer ~]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
portainer/portainer   latest              62771b0b9b09        7 weeks ago         79.1MB
 
[root@Docker-Portainer ~]# docker ps
CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS              PORTS                    NAMES
243bbc9ccb89        portainer/portainer   "/portainer"        14 seconds ago      Up 13 seconds       0.0.0.0:9000->9000/tcp   portainer
 
[root@Docker-Portainer ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2020-09-15 14:26:55 KST; 42min ago
     Docs: https://docs.docker.com
 Main PID: 2393 (dockerd)
    Tasks: 23
   Memory: 135.5M
   CGroup: /system.slice/docker.service
           ├─2393 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
           └─2636 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9000 -container-ip 172.17.0.2 -container-port 9000
 
Sep 15 14:26:55 Docker-Portainer dockerd[2393]: time="2020-09-15T14:26:55.085344764+09:00" level=info msg="scheme \"unix\" not registered, fallback...ule=grpc
Sep 15 14:26:55 Docker-Portainer dockerd[2393]: time="2020-09-15T14:26:55.085371241+09:00" level=info msg="ccResolverWrapper: sending update to cc:...ule=grpc
Sep 15 14:26:55 Docker-Portainer dockerd[2393]: time="2020-09-15T14:26:55.085386293+09:00" level=info msg="ClientConn switching balancer to \"pick_...ule=grpc
Sep 15 14:26:55 Docker-Portainer dockerd[2393]: time="2020-09-15T14:26:55.113602672+09:00" level=info msg="Loading containers: start."
Sep 15 14:26:55 Docker-Portainer dockerd[2393]: time="2020-09-15T14:26:55.239871781+09:00" level=info msg="Default bridge (docker0) is assigned wit...address"
Sep 15 14:26:55 Docker-Portainer dockerd[2393]: time="2020-09-15T14:26:55.283276555+09:00" level=info msg="Loading containers: done."
Sep 15 14:26:55 Docker-Portainer dockerd[2393]: time="2020-09-15T14:26:55.302736514+09:00" level=info msg="Docker daemon" commit=48a66213fe graphdr...19.03.12
Sep 15 14:26:55 Docker-Portainer dockerd[2393]: time="2020-09-15T14:26:55.302851968+09:00" level=info msg="Daemon has completed initialization"
Sep 15 14:26:55 Docker-Portainer dockerd[2393]: time="2020-09-15T14:26:55.321042778+09:00" level=info msg="API listen on /var/run/docker.sock"
Sep 15 14:26:55 Docker-Portainer systemd[1]: Started Docker Application Container Engine.

 

4. Portainer와 Docker node 의 remote 연동 : 연동하고자 하는 docker node의 API포트를 오픈 시켜줘야 함(TLS 사용하지 않음)

## "-H tcp://0.0.0.0:2375" 옵션 추가(default가 2375)
[root@Docker-Worker3 ~]# vim /usr/lib/systemd/system/docker.service
...
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375
...
 
 
## docker 재시작
[root@Docker-Worker3 ~]# systemctl daemon-reload
[root@Docker-Worker3 ~]# systemctl restart docker
[root@Docker-Worker3 ~]# netstat -anpot | grep LISTEN
...
tcp6       0      0 :::2375                 :::*                    LISTEN      4812/dockerd         off (0.00/0/0)
tcp6       0      0 :::2377                 :::*                    LISTEN      4812/dockerd         off (0.00/0/0)
tcp6       0      0 :::7946                 :::*                    LISTEN      4812/dockerd         off (0.00/0/0)
...
 
## 참조 : 2377 : swarm node간 통신, 2375 : Portainer와의 API 통신
 
 
## swarm의 service를 생설하고자한다면 manager node 1개만 추가해도 swarm node 정보를 읽어오지만 각각의 node의 컨테이너를 개별 생성 하고자 한다면 생성하고자하는 모든 node를 추가해준다.

 

5. 연동 설정 : 연동은 웹에서 진행하며 http://portainer:9000으로 접속하면 초기 계정 설정 후 "remote"오 아래와 같은 값으로 추가한다.

반응형