LINUX
[Rocky] docker certbot duckdns 인증서 발급 방법
영은파더♥
2025. 4. 29. 13:15
728x90
docker가 설치되어 있지 않다면 docker를 설치합니다.
yum config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum -y install docker-ce docker-ce-cli containerd.io
systemctl enable docker
systemctl start docker
docker compose version 명령어로 버전명이 잘 나오는지 확인합니다.
mkdir -p ~/docker/certbot/nginx
cd ~/docker/certbot
cat << EOF > ~/docker/certbot/nginx/certbot.conf
server {
listen 80;
server_name example.duckdns.org;
location /.well-known/acme-challenge {
allow all;
root /var/www/certbot;
}
}
EOF
cat << EOF > ~/docker/certbot/docker-compose.yml
services:
nginx:
image: nginx:latest
container_name: nginx
ports:
- "80:80"
volumes:
- ./nginx:/etc/nginx/conf.d
- ./certbot/www:/var/www/certbot
certbot:
image: certbot/certbot:latest
container_name: certbot
volumes:
- /etc/letsencrypt:/etc/letsencrypt:rw
- ./certbot/logs:/var/log/letsencrypt:rw
- ./certbot/www:/var/www/certbot:rw
command: certonly --webroot -w /var/www/certbot --email 이메일주소 --no-eff-email -d example.duckdns.org --agree-tos
EOF
docker compose up
위의 코드에서 이메일주소와 example.duckdns.org 는 자신의 도메인으로 변경하고 실행하면 됩니다.
혹시 아래의 오류가 뜨면
Unable to enable DNAT rule: (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 80 -j DNAT --to-destination 172.18.0.2:80 ! -i br-c353837207ff: iptables: No chain/target/match by that name.
(exit status 1))
systemctl restart docker 재시작하고 다시 docker compose up 명령어를 실행합니다.
728x90
반응형