NTPd in Docker (docker-compose) — pool.ntp.org ready
Overview:
- A minimal repository to run ntpd via docker-compose, preconfigured to participate in pool.ntp.org.
- Default upstream servers are set to the Korea and Japan NTP servers (not pool.ntp.org).
- Serves NTP over UDP port 123.
Key points:
- UDP 123 must be open on the host firewall and any upstream firewalls/NAT devices (both inbound and outbound).
- Run with docker compose; the compose file builds the local Dockerfile.
- Includes a ready-to-use ntp.conf and docker-compose.yml.
- Suitable as a starting point to join pool.ntp.org (you still need to meet pool requirements and register your server).
Usage:
- Adjust ntp.conf if you want to change or add regional pools.
- Bring up or rebuild the service with
docker compose up -d --build.
- If you want ntpd to discipline the host clock, run with the SYS_TIME capability and ensure the container has permission to bind UDP/123.
- Docker publishes only UDP 123 from the host to the container on both IPv4
(
0.0.0.0:123) and IPv6 ([::]:123). UDP 123 must be free on the host.
- The NTP drift file is stored in a Docker named volume and survives restarts.
- Verify reachability from the internet and monitor offset/stats before registering with pool.ntp.org.
On Ubuntu with UFW, allow NTP through the host firewall (this creates the IPv4
and IPv6 rules when UFW IPv6 support is enabled):
sudo ufw allow 123/udp comment 'NTP server'
sudo ufw status verbose
Notes for pool.ntp.org participation:
- Ensure stable network, correct time, and good reachability on UDP 123.
- Prefer a static public IP and proper reverse DNS if possible.
License:
- Unlicense (public domain dedication).
개요:
- docker-compose로 ntpd를 실행하는 최소 구성 저장소이며, pool.ntp.org 참여를 염두에 둔 기본 설정을 제공합니다.
- 기본 업스트림 서버는 한국 및 일본 NTP 서버(not pool.ntp.org)로 설정되어 있습니다.
- UDP 123 포트로 NTP 서비스를 제공합니다.
핵심 사항:
- 호스트와 상위 방화벽/NAT에서 UDP 123 포트(수신/발신)가 반드시 열려 있어야 합니다.
- docker compose로 로컬 Dockerfile을 빌드하고 실행합니다.
- ntp.conf와 docker-compose.yml이 포함되어 있습니다.
- pool.ntp.org 합류를 위한 출발점으로 사용할 수 있습니다(참여 요건 충족 및 등록은 별도로 필요).
사용 방법:
-
지역에 맞는 NTP 풀로 변경하려면 ntp.conf를 수정하세요.
-
docker compose up -d --build로 이미지를 빌드하고 서비스를 시작합니다.
-
호스트 시계를 ntpd가 보정하도록 하려면 컨테이너에 SYS_TIME 권한을 부여하는 것을 권장합니다.
-
호스트 네트워크를 사용하므로 ntpd가 IPv4(0.0.0.0:123)와
IPv6([::]:123)에 직접 listen합니다. 호스트에서 UDP 123 포트가
다른 프로세스에 사용 중이지 않아야 합니다.
-
NTP drift 파일은 Docker named volume에 저장되어 재시작 후에도 유지됩니다.
-
인터넷에서의 도달성 및 시간 오프셋을 점검한 후 pool.ntp.org에 등록하세요.
Ubuntu에서 UFW를 사용한다면 다음 명령으로 호스트 방화벽의 NTP 포트를
열어야 합니다(UFW IPv6 지원이 활성화되어 있으면 IPv4/IPv6 규칙이 함께
생성됩니다).
sudo ufw allow 123/udp comment 'NTP server'
sudo ufw status verbose
참고:
- 안정적인 네트워크, 정확한 시간 유지, UDP 123 도달성 확보가 중요합니다.
- 가능하면 고정 공인 IP와 적절한 역방향 DNS를 권장합니다.
라이선스: