How to Configure Drone Port Mapping

Published
Length
3 min read

Luis Felipe Dias

All posts

A drone port mapping setup links a build container port to the host machine network. You set it up by binding only required ports to local network addresses. Teams use continuous integration pipelines to run automated tests and build software packages. During a pipeline run, one step often needs to talk to another service. By default, containers in the same pipeline share a local network space. They only need external port bindings when outside tools must reach them. How drone port mapping wo

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

A drone port mapping setup links a build container port to the host machine network. You set it up by binding only required ports to local network addresses.

Teams use continuous integration pipelines to run automated tests and build software packages. During a pipeline run, one step often needs to talk to another service. By default, containers in the same pipeline share a local network space. They only need external port bindings when outside tools must reach them.

How drone port mapping works in pipelines

In a standard pipeline, every build step runs inside its own isolated container. The pipeline runner creates a shared virtual network for all steps in one build. Because of this shared network, containers can reach each other using internal hostnames. You do not need drone port mapping for basic traffic between pipeline steps.

Port mapping becomes necessary when a workload must expose a port to the host. This affects central pipeline runners, build agents, and any external test runners. If you map a container port to the host, any process on that host can reach it. If the host has a public address, outside users might reach that port too.

Safe defaults start with avoiding host port bindings whenever an internal network works. When you must expose a port, bind it to the local loopback address. This rule stops external machines on the network from reaching the test container. You should also pick high, random port numbers to avoid clashes between parallel builds.

Network isolation and shared runner risks

Shared build runners often execute multiple pipelines at the same time on one host. If two pipelines map the same host port, the second build will fail. Worse, one pipeline might send test traffic to a container owned by another team. This cross-talk can leak test data or break build results across your team.

To prevent port clashes, teams isolate build agents or run single-use virtual machines. Each build gets a clean host network that vanishes when the job finishes. You can also restrict which repos have permission to define host port rules. Platform admins usually lock down pipeline settings for untrusted or public code repos.

End-to-End Encryption + Control Mapping: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Reviewing your runner network setup helps keep build systems safe from outside traffic. Check firewall rules on the build host to block inbound requests to dynamic ports. Make sure your runner service drops elevated network permissions before starting untrusted build steps.

Checking port rules and auditing build runs

Before you run a pipeline in production, check which ports your steps expose. You can inspect the pipeline definition file during a pull request review. Automated policy checks can scan these files and block unsafe host port bindings. This step catches overly broad network rules before the runner starts a container.

During a build, host network logs show which ports open and close. Security teams collect these logs to spot unusual network activity on build servers. Still, static pipeline rules only control how the container starts up. Once a build step starts and logs in to a database, static rules do not watch the queries.

A build container with valid database keys can run any command that role allows. If a test script has a bug, it might delete records or read sensitive tables. Pipeline logs show console output, but they rarely capture full database query histories. Teams need clear visibility into what queries and commands actually run during a build.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Do pipeline steps need port mapping to talk to service containers?

No, steps in the same pipeline share a local container network by default. They can reach service containers using the service name and internal port number.

Why does my build fail when mapping a host port?

Another build on the same runner host is likely using that exact port. Switch to internal container networking or let the host assign a random free port.

How can I stop untrusted builds from exposing host ports?

Restrict trusted repo settings in your runner control panel to admin teams only. Standard builds will not have permission to bind container ports to the host.

The query runs. The emails stay hidden.