D3-G Headless Ubuntu에서 Docker 설치 및 실행시 네트워크 관련 제약사항

안녕하세요,

Ubuntu | Docker Docs

위 가이드에 따라 D3-G 보드(Headless Ubuntu)에 Docker Engine을 설치하여 테스트를 하고 있습니다.

그런데, default network인 Bridge Network를 사용하기에 필요한 커널 모듈들이 없는 것 같습니다. (아래 모듈 리스트는 ChatGPT를 통해 얻은 정보이므로 틀릴 수 있습니다.)

  • ip_tables
  • iptable_raw
  • iptable_filter
  • iptable_nat
  • iptable_mangle

그래서 처음 docker engine 설치 후, 아래와 같이 결과가 나옵니다.

root@TOPST:~# sudo docker run --rm hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Run 'docker run --help' for more information
root@TOPST:~#

아래와 같이 Docker 데몬 설정을 변경하여 iptables와 bridge network를 사용하지 않도록 하여 실행하면 정상 동작이 됩니다.

# Docker 서비스 중지
sudo systemctl stop docker

# Docker 데몬 설정 파일 생성/수정
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json > /dev/null <<EOF
{
  "iptables": false,
  "bridge": "none"
}
EOF

# Docker 서비스 재시작
sudo systemctl start docker

아래는 그 후 정상 동작되는 모습입니다.

root@TOPST:~# sudo docker run --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.
    (arm64v8)
 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/

root@TOPST:~#

아래는 host 모드로 네트워크 사용시 정상 작동하고, bridge 모드로 네트워크 사용시 되지 않는 모습입니다.(위와 같이 daemon.json 파일 설정 후)

root@TOPST:~# sudo docker run --rm --network host alpine ping -c 3 google.com
PING google.com (172.217.25.174): 56 data bytes
64 bytes from 172.217.25.174: seq=0 ttl=117 time=33.081 ms
64 bytes from 172.217.25.174: seq=1 ttl=117 time=33.243 ms
64 bytes from 172.217.25.174: seq=2 ttl=117 time=33.462 ms

--- google.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 33.081/33.262/33.462 ms
root@TOPST:~#
root@TOPST:~# sudo docker run --rm --network bridge alpine ping -c 3 google.com
ping: bad address 'google.com'
root@TOPST:~#

Bridge network가 기본 네트워크 모드인 만큼, 중요한 기능이라고 생각되어 집니다. 혹시 관련하여 필요한 모듈을 포함하여 커널을 빌드하여 이미지를 배포해 줄 수 있을까요?

안녕하세요. TOPST 입니다.

우선, 현재 Release 된 Kernel은 Bridge 모드가 활성화 되어 있습니다.
해서, 아래와 같이 bridge 네트워크를 만들어 주세요.

root@TOPST# vi /etc/netplan/99-default.yml

network:
  version: 2
  ethernets:
    eth0:
      dhcp4: true
      optional: true
// 아래와 같이 bridge network 추가
  bridges:
    br0:
      interfaces: [eth0]
      dhcp4: yes

root@TOPST# netplan apply
root@TOPST# ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.137.160  netmask 255.255.255.0  broadcast 192.168.137.255
        inet6 fe80::7c0c:bdff:fef7:fd03  prefixlen 64  scopeid 0x20<link>
        ether 7e:0c:bd:f7:fd:03  txqueuelen 1000  (Ethernet)
        RX packets 17  bytes 3742 (3.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 20  bytes 2106 (2.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether c6:4b:82:9a:fd:25  txqueuelen 1000  (Ethernet)
        RX packets 535  bytes 636027 (636.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 317  bytes 27532 (27.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 89  base 0x8000

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 670  bytes 48992 (48.9 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 670  bytes 48992 (48.9 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

iptables는 apt install 을 사용해 설치가 가능하십니다.

더 궁금한 점이 있으시면 댓글 주세요.

고맙습니다.

제가 말한 bridge network는 docker container network mode 중 하나입니다. (참고)
본래, docker run 명령어를 통해서 컨테이너를 실행하면 자동적으로 bridge network가 생기게 됩니다. 그래서 수동으로 생성하는 게 맞지 않는 것 같습니다.

또한, apt install iptables를 진행하면, 이미 최신버전으로 설치되어 있다고 뜹니다.(1.8.7-1ubuntu5.2)

그래서 말씀하신 대로 해도 동일하게 작동되지 않습니다. 제가 놓친 것이 있을까요?

안녕하세요.

상위 답변은 질문에 대한 정확한 답변이 아니었네요. 죄송합니다.

말씀하신대로, docker 가 설치되면서 bridge가 설정이 되어야 합니다.
현재 기본적인 docker 설치를 따르면, bridge network가 설정이 안되는 것을 확인했고,
몇 가지 주변 설정을 거쳐, bridge 가 활성화 되는 것은 확인했습니다.

하지만 여전히 커널 빌드가 필요한 옵션들이 몇 가지 있어서, 최종 확인 후에 다시 답변을 드리도록 하겠습니다.

고맙습니다.

1 Like

안녕하세요.

docker의 bridge network 활성화하고
커널 기능을 추가해 hello world가 bridge network를 이용해 정상적으로 실행되는 것을 확인했습니다.

ubuntu headless image 와 함께, docker 구동 가이드를 배포할 예정입니다만,
내부 인증 절차를 거쳐야 하는 관계로 시간이 조금 걸릴 듯 합니다.

예상 일정은 7월 11일로 보이니 조금만 기다려 주세요.

고맙습니다.

1 Like