> ## Documentation Index
> Fetch the complete documentation index at: https://sitectl.libops.io/llms.txt
> Use this file to discover all available pages before exploring further.

# port-forward

> Access internal Docker Compose service ports without publishing them on the host.

export const Compose = () => <Tooltip headline="Compose" tip={<>
        Docker Compose is Docker's tool for defining and running multi-container applications.{" "}
        <a href="https://docs.docker.com/compose/">https://docs.docker.com/compose/</a>.
      </>}>
    <>
      <Icon icon="docker" />
      {" "}
      Compose
    </>
  </Tooltip>;

Solr, Traefik's dashboard, migration-only application routes, and similar interfaces are often available only inside a <Compose /> network. `port-forward` maps one or more of those service ports to loopback ports on your workstation without adding a public `ports:` entry to the project.

`port-forward` is a core `sitectl` command. It works for local and remote contexts and is not provided by an application plugin. At least one `LOCAL-PORT:SERVICE:REMOTE-PORT` mapping is required.

## Reference

Access a Docker Compose service without publishing its port on the host.

Every listener is bound to 127.0.0.1. Remote contexts forward over SSH,
local Linux contexts use the container network directly, and local Docker
Desktop contexts stream through BusyBox nc inside the selected service
container.

As an example, from a local machine, accessing your stage context's traefik dashboard and solr admin UI
could be done by running this command in the terminal:

sitectl port-forward \
8983:solr:8983 \
8080:traefik:8080 \
8161:activemq:8161 \
`--context` stage

Then, while leaving the terminal open, in your web browser you can visit

[http://localhost:8983/solr](http://localhost:8983/solr) to see the solr admin UI
[http://localhost:8080/dashboard](http://localhost:8080/dashboard) to see the traefik dashboard (assuming it's enabled in your config)
[http://localhost:8161/admin/queues.jsp](http://localhost:8161/admin/queues.jsp) to see ActiveMQ queues

Be sure to run Ctrl+c in your terminal when you are done to close the connection.

```bash theme={null}
sitectl port-forward [LOCAL-PORT:SERVICE:REMOTE-PORT...]
```

## Transport and exposure

Every local listener binds to `127.0.0.1`, so the forward is reachable from the same workstation but is not published to its LAN interfaces.

| Context              | Transport                                                                                               |
| -------------------- | ------------------------------------------------------------------------------------------------------- |
| Remote               | Resolves the running service container on the remote Docker host and carries the connection through SSH |
| Local Linux          | Connects directly to the service container on its <Compose /> network                                   |
| Local Docker Desktop | Streams through `busybox nc` inside the selected service container                                      |

Services are identified by their <Compose /> service name and must already have a running container. Docker Desktop forwarding also requires the service image to provide BusyBox `nc`; LibOps application images include it. The command fails if a requested local port is already occupied.

Leave the command running while you use the forwarded endpoints. Press `Ctrl+C` to close every listener and active connection.
