自宅サーバのDocker NetworkのIPアドレスプールが枯渇した

https://twitter.com/aoirint/status/1617993934625722368 弊自宅サーバでは、サーバソフトウェアや定期実行プログラムのデプロイに、基本的にDocker Composeを使用しています。 先日、新しいソフトウェアをDocker Composeでデプロイしようとして、以下のエラーが発生しました。 Error response from daemon: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network Docker Networkが使用するIPアドレスプールが枯渇し、新しいIPアドレスブロックを確保できなかったという内容のエラーです。 環境 Ubuntu 20.04 $ docker -v Docker version 20.10.23, build 7155243 $ docker compose version Docker Compose version v2.15.1 原因 このエラーは、30個程度のDocker Networkを作成すると発生するようです。 Docker Composeでは通常、プロジェクト1つあたり、1つのDocker Networkが作成されます(複雑なプロジェクトでは、2つ以上使用することがあるかもしれません)。 手元の環境では、Docker Composeのプロジェクトが27個稼働しており、28個目のプロジェクトを起動したときにエラーが発生しました。 Docker Networkの一覧は、以下のコマンドで確認できます。 docker network ls Docker NetworkのIPアドレスには、いわゆるプライベートIPアドレスの範囲が使用されます。 プライベートIPアドレスの範囲は、以下のようになります(CIDR表記)。 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 作成されたDocker Networkに割り当てられたIPレンジはdocker network inspectコマンドで確認できます。 以下の記事で紹介されているコマンドが便利です。 ...

2023年1月26日 · aoirint

HashiCorpのapt GPGキーを更新する

$ sudo apt update Err:2 https://apt.releases.hashicorp.com focal InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA16FCBCA621E701 W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://apt.releases.hashicorp.com focal InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA16FCBCA621E701 W: Failed to fetch https://apt.releases.hashicorp.com/dists/focal/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA16FCBCA621E701 W: Some index files failed to download. They have been ignored, or old ones used instead. https://developer.hashicorp.com/terraform/cli/install/apt wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list

2023年1月25日 · aoirint

自宅ネットワークのbind9をdocker composeに移行した

自宅ネットワークのbind9をdocker compose化したので記録。 これまでホストで直接動かしていたけれど、OOM Killerか何かに3,4日に1度くらいでキルされていたので不便だった これでdocker composeのrestart機構で再起動がかかるようになる systemdのrestart機構ワカラナイ Dockerイメージ: https://hub.docker.com/r/ubuntu/bind9 コード docker-compose.yml services: bind9: image: ubuntu/bind9:9.18-22.04_beta restart: always ports: - "0.0.0.0:53:53/udp" volumes: - "./volumes/bind_etc/named.conf.local:/etc/bind/named.conf.local:ro" - "./volumes/bind_etc/named.conf.options:/etc/bind/named.conf.options:ro" - "./volumes/bind_var_cache:/var/cache/bind:rw" - "./volumes/bind_var_lib:/var/lib/bind:rw" environment: - "TZ=Asia/Tokyo" - "BIND9_USER=bind" # UID=101 volumes/bind_etc/named.conf.options acl my-network { 10.0.0.0/8; 172.16.0.0/12; 192.168.0.0/16; localhost; }; options { directory "/var/cache/bind"; response-policy { zone "rpz"; }; allow-query { any; }; allow-recursion { my-network; }; allow-query-cache { my-network; }; dnssec-validation auto; forward only; forwarders { # ISP DNS1; # ISP DNS2; 8.8.8.8; 8.8.4.4; 1.1.1.1; }; } volumes/bind_etc/named.conf.local zone "example.com" IN { type master; file "example.com.zone"; }; zone "rpz" { type master; file "rpz.zone"; allow-query { none; }; }; volumes/bind_var_cache/example.com.zone $ORIGIN example.com. $TTL 3600 @ IN SOA ns.example.com. root.example.com ( 2023012500 ; Serial 3600 ; Refresh 900 ; Retry 604800 ; Expire 86400 ; Minimum ) IN NS ns.example.com. ns IN A 127.0.0.1 @ IN A 127.0.0.1 sub IN CNAME example.com. volumes/bind_var_cache/rpz.zone $TTL 3600 @ IN SOA localhost. root.localhost. ( 2023012500 ; Serial 3600 ; Refresh 900 ; Retry 604800 ; Expire 86400 ; Minimum ) IN NS localhost. ; block malicious domains malicious.example.com A 0.0.0.0 既知の問題 libvirt dnsmasqが53/udpを先に取ると動かなくなりそう? ホストのbind9をアンインストール sudo apt purge bind9 sudo rm -rf /var/cache/bind/

2023年1月25日 · aoirint

TwitterのふぁぼとPixivのブクマを保存するスクリプト

https://github.com/aoirint/twifavoritedl https://github.com/aoirint/xivbookmarkdl

2023年1月18日 · aoirint

Minecraft Villager Data

Bedrock Edition 1.19.50 (2022-11-29) https://learn.microsoft.com/en-us/minecraft/creator/reference/source/vanillabehaviorpack_snippets/entities/villager_v2 https://wiki.bedrock.dev/documentation/queries.html Variant Numeric ID String ID 0 unskilled 1 farmer 2 fisherman 3 shepherd 4 fletcher 5 librarian 6 cartographer 7 cleric 8 armorer 9 weaponsmith 10 toolsmith 11 butcher 12 leatherworker 13 mason 14 nitwit TradeTablePath String ID TradeTablePath unskilled (undefined) farmer trading/economy_trades/farmer_trades.json fisherman trading/economy_trades/fisherman_trades.json shepherd trading/economy_trades/shepherd_trades.json fletcher trading/economy_trades/fletcher_trades.json librarian trading/economy_trades/librarian_trades.json cartographer trading/economy_trades/cartographer_trades.json cleric trading/economy_trades/cleric_trades.json armorer trading/economy_trades/armorer_trades.json weaponsmith trading/economy_trades/weapon_smith_trades.json toolsmith trading/economy_trades/tool_smith_trades.json butcher trading/economy_trades/butcher_trades.json leatherworker trading/economy_trades/leather_worker_trades.json mason trading/economy_trades/stone_mason_trades.json" nitwit Skin ID Skin ID 1 2 3 4 5 MarkVariant MarkVariant Name 0 plains 1 desert 2 jungle 3 savanna 4 snow 5 swamp 6 taiga Java Edition 1.19.3 Command references https://minecraft.fandom.com/wiki/Tutorials/Useful_commands#Villager_Trades

2022年12月10日 · aoirint

aoirint.com 個人用メールサーバ

2022-12-09より、aoirint.comにて、個人用メールサーバの運用を始めました。 aoirint.comアドレス宛てにメールが送信できない、受信できない、不正中継されている、セキュリティ上の問題などがあれば、Twitter、Mastodon、Keybaseなどにご連絡ください。 更新履歴 2022-12-09 運用開始 構成 DNS DNSでは、MXレコード、SPFレコードを設定しています。 外部からのメールを内部に転送するSMTPサーバ mx01.aoirint.com SMTP 暗号化 STARTTLS(必須) 認証 なし ホスト名(TLS証明書のコモンネーム) mx01.aoirint.com ポート番号 25 外部へのメール送信 禁止 SMTPS 暗号化 暗黙的TLS 認証 なし ホスト名(TLS証明書のコモンネーム) mx01.aoirint.com ポート番号 465 外部へのメール送信 禁止 外部にメールを送信するSMTPサーバ smtp.aoirint.com Submission 暗号化 STARTTLS(必須) 認証 平文パスワード ホスト名(TLS証明書のコモンネーム) smtp.aoirint.com ポート番号 587 外部へのメール送信 許可(認証必須) IMAPサーバ imap.aoirint.com IMAPS 暗号化 暗黙的TLS 認証 平文パスワード ホスト名(TLS証明書のコモンネーム) imap.aoirint.com ポート番号 993 POP3サーバ pop.aoirint.com POP3S 暗号化 暗黙的TLS 認証 平文パスワード ホスト名(TLS証明書のコモンネーム) pop.aoirint.com ポート番号 995

2022年12月9日 · aoirint

HTTPリクエストからOriginヘッダを削除(Manifest V3 Chrome拡張, Chrome 101+)

動作環境 Google Chrome 108 Manifest V3 内容 Chrome拡張から送られるHTTPリクエストについて、 ローカルで動くHTTPサーバhttp://127.0.0.1:8000のOriginチェックを回避するため、 Originヘッダを削除します。 declarativeNetRequest機能を使用します。manifest.jsonのpermissionsにdeclarativeNetRequestWithHostAccess(Chrome 96+)の追記が必要です。 加工するHTTPリクエストを、この拡張機能から送られるHTTPリクエストに絞るため、initiatorDomainsオプション(Chrome 101+)を使用しています。将来的に、より厳密な検査ができるオプションが追加される可能性があります。 chrome.declarativeNetRequestのドキュメント: https://developer.chrome.com/docs/extensions/reference/declarativeNetRequest/ また、CORSを回避するには、manifest.jsonのhost_permissionsにhttp://127.0.0.1:8000/*を追記します。 https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/host_permissions XMLHttpRequest and fetch access to those origins without cross-origin restrictions (though not for requests from content scripts, as was the case in Manifest V2). background.js // license: CC0 chrome.declarativeNetRequest.updateDynamicRules({ removeRuleIds: [1], addRules: [ { id: 1, priority: 1, action: { type: 'modifyHeaders', requestHeaders: [ { 'header': 'Origin', 'operation': 'remove' }, ], }, condition: { urlFilter: '127.0.0.1:8000/*', initiatorDomains: [chrome.runtime.id], // chrome-extension://{extension_id} }, }, ], })

2022年12月7日 · aoirint

2022-12-04から2022-12-06にかけてmstdn.aoirint.comで発生していた障害について

2023-02-10: タイトル・文言の修正 2022-12-04 03:40頃から、mstdn.aoirint.comで障害が発生していました。 2022-12-04 03:40頃 障害発生(WAN側IPアドレスの変更) 2022-12-06 15:00頃 障害を認識、原因を特定、DNSレコードを変更 2022-12-06 15:10頃 TTL経過により解消の見込み サービスの死活監視 サービスの死活監視は、内部ネットワークのSmokePing、および外部ネットワークのBetter Uptimeを使用しています。 以下の画像は、2022-12-04 00:00から06:00における、SmokePingによるNATループバックPingの監視記録です。 これ以降、SmokePingの宛先IPアドレス変更が行われるまで、不通の状態が続きました。 現在のサーバ環境では、原因を特定できていない短時間の接続不良が毎日のように発生しており、 今回の障害ではBetter Uptimeの停止通知が一時的なものでないことに気づかないまま、48時間以上経過することになりました。 今後の対応について、DDNSサービスやCloudflare等を活用したサーバ環境の安定化対策を検討しています。

2022年12月6日 · aoirint

Mastodon on Docker Composeで全文検索エンジンElasticsearchを有効化する

Mastodon on Docker Composeを立てる記事: https://blog.aoirint.com/entry/2020/mastodon_docker/ 上の記事では、諸般の事情(主にスペック不足)によりElasticsearchを無効化した状態でMastodonインスタンスを立てていた。 2021年のElasticsearchのライセンス変更 クラウド事業者によるマネージドサービス提供における、オープンソースコミュニティへのコントリビューションの不足等を背景として、 2021年のバージョン7.11リリース以降、ElasticsearchのライセンスはApache 2.0から独自のElastic License 2.0(およびServer Side Public Licenseのデュアルライセンス)に変更された。 https://www.elastic.co/jp/pricing/faq/licensing この記事では、Elastic License 2.0によってライセンスされる公式のElasticsearchの配布パッケージを使用する。 Elastic License 2.0の条文: https://www.elastic.co/licensing/elastic-license ちなみにElastic License 2.0は、Elasticsearchをマネージドサービスとして提供することを禁止しているが、SaaSアプリケーションのバックエンドとして使用すること(Elasticsearch APIへの直接アクセスを提供しないサービス提供)に影響しないという立場が示されている。 Elasticsearchをバックエンドで使用するSaaSアプリを開発しているけど、どんな影響が生じる? 今回のソースコードのライセンス変更はお客様に一切影響しません。Elastic Licenseに基づいて、デフォルトの配布パッケージを使用できるほか、このパッケージをベースに無料でアプリケーションを開発することもできます。Elastic Licenseはsource-available license(ソース利用許諾)であり、コピーレフトの側面を持たず、デフォルトの機能を無料とします。具体的な例として、よろしければMagentoプロジェクトに関する質問への回答をご参照ください。 https://www.elastic.co/jp/pricing/faq/licensing#elasticsearch%E3%82%92%E3%83%90%E3%83%83%E3%82%AF%E3%82%A8%E3%83%B3%E3%83%89%E3%81%A7%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8Bsaas%E3%82%A2%E3%83%97%E3%83%AA%E3%82%92%E9%96%8B%E7%99%BA%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E3%81%91%E3%81%A9%E3%80%81%E3%81%A9%E3%82%93%E3%81%AA%E5%BD%B1%E9%9F%BF%E3%81%8C%E7%94%9F%E3%81%98%E3%82%8B%EF%BC%9F I’m using Elasticsearch to put a search box on my cat-picture SaaS product. This is permitted under ELv2. Meow! I am a Managed Service Provider (MSP) running Elasticsearch and Kibana for my customers. If your customers do not access Elasticsearch and Kibana, this is permitted under ELv2. If your customers do have access to substantial portions of the functionality of either Elasticsearch and Kibana as part of your service, this may not be permitted. ...

2022年11月23日 · aoirint

死活監視サービスBetter Uptimeを導入した

aoirint.com関連サービスにBetter Uptimeを導入し、死活監視情報の提供を開始しました。 登録時に電話番号が必要なのがネックだけれど、URLを入力して、オプションでカスタムドメインを使うためにDNSにCNAMEレコードを追加したくらいで、結構簡単に使い始められた。 プランは以下を参照。URL 10個まで無料で監視させられる(3分間隔)。 https://betterstack.com/better-uptime/pricing カスタムドメインのステータスページ。 https://status.aoirint.com

2022年11月23日 · aoirint