Moonglade

Modern Markdown blogging with AI-powered localization and search.

Tag: Docker




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 358
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 219
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 426
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 1,668
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 669
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 615
Container Docker Linux Locale bash timezone

Run Linux Desktop experience in Docker container

This article provides an in-depth analysis of the key software package dependencies required to run a Linux desktop environment within a Docker container. It begins by identifying `gnome-shell` as a core component, noting that its dependencies include specific configurations such as the Ubuntu wallpaper. The article then clearly distinguishes between the roles of `gnome-core` and `ubuntu-desktop`, explaining that Ubuntu installs the latter by default rather than the former, and lists core application dependencies, including the file manager, terminal, and settings center. Additionally, it highlights Ubuntu-specific GNOME Shell extensions, such as `ubuntu-dock` for the taskbar, application indicator support, and desktop icon management tools. Finally, it compares the dependency differences between `ubuntu-desktop-minimal` and the standard `ubuntu-desktop`. The former provides a basic environment for minimal installations, while the latter adds more standard components on top of that foundation. By mapping out these dependency chains, readers can clearly understand how to build a fully functional yet lightweight Linux desktop environment in Docker, enabling convenient testing and experience of the desktop system without the need for a local installation.

Views 993
Docker Gnome Linux Remote Management Ubuntu desktop