Qin's Blog - Docker
type: channel
link: https://llb.im/tag/Docker/
items: Docker出口使用不同公网IP
items: Docker私有仓库Registry搭建
items: 使用Miniflux搭建RSS服务

Docker出口使用不同公网IP
type: item
date: 2024-05-23T05:28:00+00:00
description: iptables方法iptables -t nat -I POSTROUTING -s 172.18.0.10 ! -o docker1 -j SNAT --to 192.168.0.100 # 172.18.0.10 = 容器ip # docker1 = docker network网卡 # 192.168.0.100 = 公网ip 这里为VPC IP容器自定义IP不能使用默认的docker0 networkipvlan方法docker network create -d ipvlan \ --subnet=192.168.0.0/24 \ --gateway=192.168.0.1 \ -o ipvlan_mode=l2 \ -o parent=ens3 docker1将公网ip直接接入容器，与宿主机同MAC缺点：主机无法再使用此公网ip

Docker私有仓库Registry搭建
type: item
date: 2024-03-03T15:16:00+00:00
description: 需求利用docker容器搭建Docker私有仓库Registry，并配置授权账号密码为admin。同时利用caddy反向代理实现tls访问。环境安装以下内容基于Debian10# 安装docker apt -y install wget curl wget -qO- https://get.docker.com/ | bash # 安装apache2-utils apt -y install apache2-utils # 安装caddy sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list sudo apt update sudo apt install caddy密码生成与容器启动mkdir /opt/repo/{auth,registry} -p cd /opt/repo/ htpasswd -Bbn admin admin > auth/htpasswd docker run -itd -p 5000:5000 --restart=always --name registry -v /opt/repo/registry:/var/lib/registry -v /opt/repo/auth:/auth -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" registry:latestcaddy配置与启动配置文件/etc/caddy/Caddyfile内容写为：{ servers :80 { timeouts { read_body 120s } } servers :443 { timeouts { read_body 120s } } } repo.llb.im { tls ssl@repo.llb.im encode gzip reverse_proxy 127.0.0.1:5000 }重启caddysystemctl restart caddy

使用Miniflux搭建RSS服务
type: item
date: 2023-06-25T05:13:00+00:00
description: 前言见前文 搭建RSS服务的想法 一直有一个搭建RSS信息流的想法 我的浏览器收藏夹里有许多的博客，但我并没有那种 想一一打开浏览、看看他们更新了没有 的想法 所以并不能及时看到一些东西 晚上偶尔在某个被制裁... 2023-06-25 阅读全文 搭建Docker-Compose我打算用docker来跑，比较方便，依据官方文档改改，建个目录写下docker-compose.yaml文件：services: miniflux: image: miniflux/miniflux:latest ports: - "14322:8080" depends_on: db: condition: service_healthy environment: - DATABASE_URL=postgres://miniflux:secret@db/miniflux?sslmode=disable - RUN_MIGRATIONS=1 - CREATE_ADMIN=1 - ADMIN_USERNAME=admin - ADMIN_PASSWORD=test123 db: image: postgres:15 environment: - POSTGRES_USER=miniflux - POSTGRES_PASSWORD=secret volumes: - ./miniflux-db:/var/lib/postgresql/data healthcheck: test: ["CMD", "pg_isready", "-U", "miniflux"] interval: 10s start_period: 30s更改变量管理员账户密码： - ADMIN_USERNAME=admin - ADMIN_PASSWORD=test123Run：docker-compose up -dNginx再用nginx反向代理一下：location / { proxy_pass http://127.0.0.1:14322; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_max_temp_file_size 0; }登录 加RSS源这部分不赘述。RSS源可围观DIYgod大佬的RSSHub