Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9cd28f7
commit 7678b8e
Showing
2 changed files
with
38 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
--- | ||
Description: "How telepresence intercept can run a Docker container with configured environment and volume mounts." | ||
Description: "How a Telepresence intercept can run a Docker container with configured environment and volume mounts." | ||
--- | ||
|
||
# Using Docker for intercepts | ||
|
||
The Telepresence intercept command can automatically run a Docker container which has been configured with the environment and volume mounts of the intercepted service. This is done using the option `--docker-run`. | ||
If you want your intercept to go to a Docker container on your laptop, use the `--docker-run` option. It creates the intercept, runs your container in the foreground, then automatically ends the intercept when the container exits. | ||
|
||
`telepresence intercept [service] --port [port] --docker-run -- [arguments]` | ||
`telepresence intercept <service_name> --port <port> --docker-run -- <arguments>` | ||
|
||
This command will intercept a service and start `docker run` in the foreground. The intercept ends when the run ends. | ||
The `--` separates flags intended for `telepresence intercept` from flags intended for `docker run`. | ||
|
||
Telepresence will automatically pass some relevant flags to Docker in order to connect the container with the intercept. Those flags are combined with the arguments given after `--` on the command line (the `--` separates flags intended for `telepresence intercept` from flags intended for `docker run`). | ||
## Example | ||
|
||
The `--port` flag can specify an additional port when `--docker-run` is used so that the local and container port can be different. This is done using `--port [local port]:[container port]`. The container port will default to the local port when using the `--port [port]` syntax | ||
Imagine you are working on a new version of a your frontend service. It is running in your cluster as a Deployment called `frontend-v1`. You use Docker on your laptop to build an improved version of the container called `frontend-v2`. To test it out, use this command to run the new container on your laptop and start an intercept of the cluster service to your local container. | ||
|
||
The flags that telepresence will pass (invisibly) to `docker run` are: | ||
`telepresence intercept frontend-v1 --port 8000 --docker-run -- frontend-v2` | ||
|
||
- `--dns-search tel2-search` Enables single label name lookups in intercepted namespaces. | ||
- `--env-file [file]` Loads the intercepted environment. | ||
- `--name intercept-{intercept name}-{intercept port}` Names the Docker container. This flag is omitted if explicitly given on the command line. | ||
- `-p [port:container-port]` The local port for the intercept and the container port. | ||
- `-v [local mount dir:docker mount dir]` Volume mount specification. See CLI help for `--mount` and `--docker-mount` flags for more info. | ||
## Ports | ||
|
||
The `--port` flag can specify an additional port when `--docker-run` is used so that the local and container port can be different. This is done using `--port <local port>:<container port>`. The container port will default to the local port when using the `--port <port>` syntax. | ||
|
||
## Flags | ||
|
||
Telepresence will automatically pass some relevant flags to Docker in order to connect the container with the intercept. Those flags are combined with the arguments given after `--` on the command line. | ||
|
||
- `--dns-search tel2-search` Enables single label name lookups in intercepted namespaces | ||
- `--env-file <file>` Loads the intercepted environment | ||
- `--name intercept-<intercept name>-<intercept port>` Names the Docker container, this flag is omitted if explicitly given on the command line | ||
- `-p <port:container-port>` The local port for the intercept and the container port | ||
- `-v <local mount dir:docker mount dir>` Volume mount specification, see CLI help for `--mount` and `--docker-mount` flags for more info |