Vultr CentOS8 에서 Docker 설치하기 (완전판)

Updated on

https://ggami.net/638/centos8-docker-%ec%84%a4%ec%b9%98%ed%95%98%ea%b8%b0/

해당 내용을 이어서 쓰는거이긴 하지만… 그냥 명령어만 작성해놓겠음.
아주 간단하게 Vultr 에서 CentOS8 기준으로 Docker 설치해서 서비스 올려야할때 이거만 보고 따라하면 끝.

sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf repolist -v
sudo dnf update
sudo dnf install docker-ce --nobest

docker -v

systemctl enable docker
curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

docker-compose --version
systemctl daemon-reload
systemctl restart docker
docker info
docker run --dns 8.8.8.8 busybox nslookup google.com
docker run busybox nslookup google.com

nslookup: write to '108.61.10.10': No route to host
;; connection timed out; no servers could be reached
 docker network create frontend
 docker network create backend
ifconfig

br-91b6f0ce06ff: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.19.0.1  netmask 255.255.0.0  broadcast 172.19.255.255
        ether 02:42:fd:cb:c5:6e  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

br-de3921a50a52: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255
        ether 02:42:68:72:5c:0c  txqueuelen 0  (Ethernet)
        RX packets 70967  bytes 219139773 (208.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 48535  bytes 5113144 (4.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        inet6 fe80::42:8fff:fed3:d5b6  prefixlen 64  scopeid 0x20<link>
        ether 02:42:8f:d3:d5:b6  txqueuelen 0  (Ethernet)
        RX packets 4  bytes 196 (196.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 852 (852.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
firewall-cmd --list-all-zones
firewall-cmd --permanent --zone=trusted --add-interface=docker0
firewall-cmd --permanent --zone=trusted --add-interface=br-91b6f0ce06ff
firewall-cmd --permanent --zone=trusted --add-interface=br-de3921a50a52

firewall-cmd --reload
systemctl restart docker

docker run busybox nslookup google.com

이렇게하면… 일단 docker 설치 및 세팅은 끝이난다. (외부접속 아이피 기록 가능)

여기서 추가적으로… docker를 업로드하고서… 명령어를 치면되는데..

docker-compose up -d --build

이렇게.. 빌드할때에 만약에 composer proc_open() 에러가 발생한다면,

스왑생성
free -m

/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1

스왑삭제
swapoff /var/swap.1
rm -f /var/swap.1

docker-compose 로 컨테이너를 생성했다면,

docker exec -it 69ee26a7c0d4 /bin/bash
composer dump-autoload --optimize

chgrp -R www-data storage bootstrap/cache
chmod -R ug+rwx storage bootstrap/cache

php artisan optimize
php artisan optimze:clear

끝.