Senin, 06 November 2023

DOCKER PORTAINER-centos8

 

Install Docker and Portainer Docker Manager on CentOS 8

https://sys-ops.id/install-portainer-docker-manager-on-centos-8/

Install Docker dan Portainer Docker Manager pada CentOS 8

Portainer adalah aplikasi open source yang digunakan untuk membangun, mengelola, dan memelihara Docker environment dengan mudah.


Install Docker CE

  • Update repository centos dan install dependencies
sudo yum update -y
sudo yum install -y yum-utils lvm2 device-mapper device-mapper-persistent-data device-mapper-event device-mapper-libs device-mapper-event-libs
  • Menambahkan repository docker-ce
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  • Update RPM index cache
yum makecache
  • Remove old docker jika pada server mempunyai docker versi lama
yum remove -y docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine podman runc
  • Install Docker-CE versi terbaru
yum install docker-ce docker-ce-cli containerd.io -y
  • Jalankan service docker
systemctl enable docker
systemctl start docker
systemctl status docker
  • Cek versi docker
docker version
Client: Docker Engine - Community
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:45:22 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.12
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.12
  Git commit:       459d0df
  Built:            Mon Dec 13 11:43:44 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
  • Tambahkan user agar bisa menjalan docker tanpa root
sudo usermod -aG docker user_Linux_selain_root 
newgrp docker
  • Verifikasi instalasi Docker CE dengan menjalankan image hello-world
docker pull hello-world

Using default tag: latest
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:507ecde44b8eb741278274653120c2bf793b174c06ff4eaa672b713b3263477b
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest
docker images

REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    feb5d9fea6a5   4 months ago   13.3kB
docker run -it --rm hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
centos8-install-docker-1

Install Docker Compose

  • Download docker compose versi terbaru
curl -s https://api.github.com/repos/docker/compose/releases/latest | grep browser_download_url  | grep docker-compose-linux-x86_64 | cut -d '"' -f 4 | wget -qi -
  • Tambahkan permission execute dan copy file ke directory /usr/local/bin
chmod +x docker-compose-linux-x86_64
sudo cp -R docker-compose-linux-x86_64 /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
  • Cek versi docker compose
docker-compose version
Docker Compose version v2.2.3

Setting Portainer

  • Buat persistent volume docker untuk menyimpan data portainer
docker volume create portainer_data
  • Cek lokasi volume portainer_data
docker volume inspect --format '{{ .Mountpoint }}' portainer_data
/var/lib/docker/volumes/portainer_data/_data
  • Jalankan Container Portainer-CE, secara otomatis akan mendownload image portainer
sudo docker run -d -p 9000:9000 -p 8000:8000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
  • Cek status container, portainer sudah aktif
sudo docker ps -a
CONTAINER ID   IMAGE                    COMMAND        CREATED          STATUS          PORTS                                                                                            NAMES
d5d1791ecc82   portainer/portainer-ce   "/portainer"   47 seconds ago   Up 44 seconds   0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp, 9443/tcp   portainer
  • Cek docker image
docker images
REPOSITORY               TAG       IMAGE ID       CREATED        SIZE
portainer/portainer-ce   latest    0df02179156a   7 weeks ago    273MB
hello-world              latest    feb5d9fea6a5   4 months ago   13.3kB
  • Cek iptables
iptables -nvL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy DROP 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 DOCKER-USER  all  --  *      *       0.0.0.0/0            0.0.0.0/0
    0     0 DOCKER-ISOLATION-STAGE-1  all  --  *      *       0.0.0.0/0            0.0.0.0/0
    0     0 ACCEPT     all  --  *      docker0  0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
    0     0 DOCKER     all  --  *      docker0  0.0.0.0/0            0.0.0.0/0
    0     0 ACCEPT     all  --  docker0 !docker0  0.0.0.0/0            0.0.0.0/0
    0     0 ACCEPT     all  --  docker0 docker0  0.0.0.0/0            0.0.0.0/0

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain DOCKER (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     tcp  --  !docker0 docker0  0.0.0.0/0            172.17.0.2           tcp dpt:9000
    0     0 ACCEPT     tcp  --  !docker0 docker0  0.0.0.0/0            172.17.0.2           tcp dpt:8000

Chain DOCKER-ISOLATION-STAGE-1 (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 DOCKER-ISOLATION-STAGE-2  all  --  docker0 !docker0  0.0.0.0/0            0.0.0.0/0
    0     0 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0

Chain DOCKER-ISOLATION-STAGE-2 (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 DROP       all  --  *      docker0  0.0.0.0/0            0.0.0.0/0
    0     0 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0

Chain DOCKER-USER (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0

  • Akses Portainer dengan url: http://ip_address_server:9000 (http://103.169.7.56:9000)
  • Buat user admin untuk akses ke portainer
centos8-install-portainer-docker-manager-1
centos8-install-portainer-docker-manager-2
centos8-install-portainer-docker-manager-3
centos8-install-portainer-docker-manager-4
centos8-install-portainer-docker-manager-5

Tidak ada komentar:

Posting Komentar