CentOS 8에서 docker-compose의 같은 스택에서 컨테이너 접속 불가
새로 설치한 CentOS 8.1 서버에 docker, docker-compose를 설치하고, 기존에 운영하던 CentOS 7 서버의 컨테이너들을 옮기고 있는데,
같은 네트워크에 설정된 컨테이너끼리 상대 호스트를 찾지 못하는 문제가 발생했다.
No route to host
docker-compose.yml은 아래와 같이 main 네트워크에 묶여있고, wordpress 컨테이너에서 mysql 컨테이너로 접속을 하지 못하는 것이다.
version: "3.7"
services:
mysql:
image: vsamov/mysql-5.1.73
networks:
main:
ports:
- "3356:3306"
restart: always
environment:
- "MYSQL_ROOT_PASSWORD=password"
- "TZ=Asia/Seoul"
volumes:
- "./mysql/mysqldata:/var/lib/mysql"
- "./mysql/my.cnf:/etc/my.cnf"
wordpress:
image: wordpress
networks:
main:
ports:
- "7001:80"
environment:
- "TZ=Asia/Seoul"
volumes:
- "./php/php.ini:/usr/local/etc/php/php.ini"
- "./apps/www/000-default.conf:/etc/apache2/sites-enabled/000-default.conf"
- "./apps/www/html:/var/www/html:Z"
networks:
main:
구글링으로 몇시간쯤 보내다가 깃허브에서 찾은 해결책은 firewalld의 설정을 변경하는 것.
vi /etc/firewalld/firewalld.conf
아래 FirewallBackend 의 값을 iptables로 바꿔주면 된다.
#FirewallBackend=nftables
FirewallBackend=iptables
RHEL 8.1 업데이트 중, 네트워크 부분에 변경 사항이 있는데, 기본 네트워크 패킷 필터링 프레임워크인 iptables 대신 nftables로 대체되었다고 한다.
자세한 내용은 관련 글이 많지 않아, 나중에 다시 확인을..
8.1 Release Notes Red Hat Enterprise Linux 8 | Red Hat Customer Portal
The Release Notes provide high-level coverage of the improvements and additions that have been implemented in Red Hat Enterprise Linux 8.1 and document known problems in this release, as well as notable bug fixes, Technology Previews, deprecated functional
access.redhat.com