Moonglade

Modern Markdown blogging with AI-powered localization and search.

Tag: Docker

RSS

Make Docker and Swarm truly support IPv6 while preserving visitor IPs

This article presents a complete process for configuring IPv6 for standard Docker containers and Swarm, preserving the real client source address, and safely validating the setup. Custom bridge networks can enable IPv6 and have Docker assign addresses; containers using ULA can also serve external traffic through the host’s public IPv6 address and published ports. Before creating a new Swarm, configure a dual-stack docker_gwbridge; for existing nodes, plan migration according to node type to avoid hastily rebuilding the cluster or losing application state. Swarm ingress can publish ports in host mode, without requiring the backend overlay network to migrate as well. The article also emphasizes distinguishing the TCP peer address from the visitor address forwarded by a reverse proxy, configuring trusted proxies correctly, and separately verifying the domain entry point, origin server IPv4/IPv6, recorded source address, and forged request headers. Troubleshooting should follow the packet path to check routing, firewalls, port publishing, and MTU; after restoring IPv6, recheck exposed ports and monitor both address families separately.

Views 349
Docker IPv6 Swarm Networking


Say Goodbye to Ugly Tag Suffixes: Building True Multi-Architecture Images with Docker Buildx

This article provides a comprehensive guide to building dual-architecture images for x86 and ARM64 using Docker buildx and QEMU. It begins with the installation of the base environment and the initialization of the builder, explaining how the `binfmt_misc` mechanism enables cross-platform instruction translation, allowing x86 machines to compile ARM code. The core practical section demonstrates how to use the `--platform` parameter to build multi-architecture images in one step, and explains the Manifest List principle: the builder independently compiles images for each architecture and then generates an index, ensuring that clients only download the layers corresponding to their specific architecture upon pull, thereby avoiding redundancy. The article specifically points out that multi-architecture images cannot be directly loaded into the traditional Docker local image list, recommending direct pushing or exporting in OCI format. For CI/CD scenarios, it recommends injecting QEMU support non-invasively by running the `tonistiigi/binfmt` container to keep the environment clean. Additionally, it covers verifying images using `regctl`, testing ARM images on x86 systems, a guide to avoiding common pitfalls regarding Dockerfile architecture compatibility, and an explanation of the purpose of buildx's background BuildKit containers and their resource management. Mastering these techniques enables efficient building and management of enterprise-level multi-architecture automated release pipelines.

Views 631
ARM64 Container Docker Docker Buildx Linux Multi Arch bash

Use Cloudflare with Caddy to Scrub Traffic

This article introduces a high-security reverse proxy configuration solution based on Caddy and Cloudflare. The core process uses a script to automatically fetch Cloudflare's latest IPv4 and IPv6 IP ranges and generate a `cloudflare_ips.conf` file containing the trusted proxy list and mandatory mutual TLS (mTLS) verification configuration. This configuration ensures that only Cloudflare nodes holding valid certificates can initiate requests, thereby supporting Full Strict mode. The build script `build_proxy.sh` is responsible for concatenating independent configuration files scattered across different business directories with the base baseline configuration to generate the final Caddyfile, achieving modularization and decoupling of business configurations for easier independent maintenance. During the deployment phase, the actual Cloudflare certificates are mounted into the container via Docker Volume, replacing the temporary certificates used during the build, enabling the service to perform actual work. Ultimately, this architecture implements a triple security mechanism: the use of Cloudflare certificates, strict mTLS client authentication, and trusting only Cloudflare as the front-end proxy. This design ensures extreme security while allowing backend services to transparently obtain the real client IP, balancing security and maintainability.

Views 376
ACME Caddy Cloudflare Docker MTLS Reverse Proxy

Visualize Caddy logs using Clickhouse

This article introduces how to leverage ClickHouse to build a Caddy log analysis system, enabling efficient data querying and visualization. The author first demonstrates that, after importing Caddy logs into ClickHouse, core metrics such as request volumes per business line, crawler IP identification, independent IP distribution, and CPU consumption can be rapidly aggregated through SQL statements. Additionally, the article details multiple practical query scenarios, including Top 100 popular endpoints, error code rankings, latency trend analysis based on P95/P99 percentiles, request size distribution, time-of-day traffic heatmaps, and User-Agent distribution, helping to gain deep insights into service performance and potential bottlenecks. In practice, the author successfully used this system to track and analyze a hacker's flood attack behavior, quickly locating the source of abnormal traffic through time-window filtering. Finally, the article demonstrates how to generate aesthetically pleasing visual reports using ClickHouse's built-in dashboards and the Grafana tool. The conclusion notes that setting up this infrastructure is of moderate difficulty; once established, it enables real-time monitoring of business metrics. For teams unfamiliar with application usage patterns, visualizing traffic data is an indispensable key method for evaluating business development.

Views 628
Caddy CaddyV2 Clickhouse Docker Python Superset

I set up Authentik at home, and I deeply regret not doing it sooner.

This article provides a detailed configuration guide for integrating unified identity authentication into applications such as OpenGist, Gitea, Koel, GitLab, and Nextcloud using Authentik. For applications that support OpenID Connect, configuring OAuth2 client information and environment variables enables anonymous browsing, automatic registration, user merging based on email addresses, and role-based access control based on group memberships. For example, both Gitea and GitLab can implement administrator privilege control by mapping the `groups` field, whereas Nextcloud requires a Python attribute mapping script to handle specific admin roles and user ID matching logic. For Koel, which does not support OIDC, the Caddy Forward Auth mechanism is employed to pass user information via HTTP Headers; however, this approach has limitations, including the inability to automatically merge users and limited permission management capabilities. Although the integration process involves complex attribute mapping, environment variable adjustments, and user data cleansing, and although the cost of merging users registered on different platforms later is extremely high, the benefits in reducing registration barriers and enhancing the user experience are significant. The article strongly recommends deploying Authentik at an early stage when the business scale is small and the user count is manageable, to avoid the substantial operational burden and communication...

Views 2,037
Authentik Docker Linux OAuth OAuth 2.0 OIDC

Set up a local Docker registry mirror

This article introduces how to use a self-hosted Docker registry to mirror images to a local server, thereby resolving network access issues and improving pull speeds. The core content covers the implementation of an automated mirroring script. This script handles the retry mechanism using an exponential backoff algorithm and supports batch synchronization of numerous Docker images, including databases, programming language runtimes, and various applications. The article details two deployment methods: first, installing Python dependencies directly on a Linux host and executing the script; second, building a Docker container that includes cron scheduled tasks to achieve daily automatic synchronization. Finally, the guide provides specific steps for configuring the Docker daemon to trust a local insecure registry, demonstrating how to pull and push images from the local registry. This solution provides an efficient and stable private image source for users who require offline environments or need to optimize image distribution efficiency, effectively reducing reliance on external network services.

Views 882
Automation Docker Mirroring Python Registry Scripting

Some quick Docker tips

Common Docker Tips and Tricks The following are some useful Docker commands and techniques that can help you manage your containers and images more effectively. Each section includes explanations of when and how to use these commands. Build an Image from a Dockerfile bash docker ...

Views 734
Container Docker Linux Locale bash timezone