Unable to install and run telepresence inside a docker container
devashish2203 opened this issue · comments
Describe the bug
I am trying to setup telepresence inside a docker container to run on CI. But when running the telepresence binary I get the following error
/bin/sh: telepresence: not found
To Reproduce
For this I setup a simple Docker image using the following Dockerfile based on https://github.com/telepresenceio/telepresence.io/blob/master/docs/pre-release/reference/inside-container.md#running-the-container
Dockerfile
# Dockerfile with telepresence and its prerequisites
FROM alpine:3.13
# Install Telepresence prerequisites
RUN apk add --no-cache curl iproute2 sshfs
# Download and install the telepresence binary
RUN curl -fL https://app.getambassador.io/download/tel2oss/releases/download/v2.18.0/telepresence-linux-amd64 -o telepresence
RUN chmod a+x telepresence
Then I'm building the container on an Ubuntu 22.04 machine
docker build . -t telepresence-ci
Next I'm running the above container using
docker run --network=host --cap-add=NET_ADMIN --device /dev/net/tun:/dev/net/tun -it --rm telepresence-ci
# Also tried
docker run --network=host --privileged -it --rm telepresence-ci
Once inside the container when trying to run telepresence
telepresence version
The following error is shown
/bin/sh: telepresence: not found
Expected behavior
Expect to see the following output
OSS Client : v2.18.0
Root Daemon: not running
User Daemon: not running
Versions (please complete the following information):
- Output of
telepresence version
- Unable to run command, Downloading the v2.18.0 binary. - Operating system of workstation running
telepresence
commands- Ubuntu 22.04.3 LTS
- Kubernetes environment and Version [e.g. Minikube, bare metal, Google Kubernetes Engine] - NA
- Docker version - Docker version 24.0.6, build ed223bc
VPN-related bugs:
N/A
Additional context
The same version of the teleport binary works fine on the host Ubunut machine
> curl -fL https://app.getambassador.io/download/tel2oss/releases/download/v2.18.0/telepresence-linux-amd64 -o telepresence
> chmod a+x telepresence
> telepresence version
OSS Client : v2.18.0
Root Daemon: not running
User Daemon: not running
In a different docker image where the base image is Ubuntu 22.04 instead of alpine, a similar error is seen
telepresence
bash: /usr/local/bin/telepresence: cannot execute: required file not found
IN order to run Telepresence in an alpine container, you'll need the following:
RUN apk add --no-cache ca-certificates iptables iptables-legacy bash
RUN rm /sbin/iptables && ln -s /sbin/iptables-legacy /sbin/iptables
RUN rm /sbin/ip6tables && ln -s /sbin/ip6tables-legacy /sbin/ip6tables
Not sure about alpine:3.14 though. The current version is 3.20.
In general, I'd suggest using telepresence connect --docker
to start the telepresence daemon container and then telepresence intercept --docker-run
to start containers that reuses the network established by that daemon.
Thanks. I'll try out on the latest alpine and the above additional dependencies and report back.
For the other suggestion regarding telepresence connect --docker
. My end goal is to run telepresence on a docker runner in Gitlab CI, so not sure if the daemon container method would work there.
Seeing the same issue with alpine:3.20 and the above added dependency. My dockerFile now is
# Dockerfile with telepresence and its prerequisites
FROM alpine:3.20
# Install Telepresence prerequisites
RUN apk add --no-cache curl ca-certificates iptables iptables-legacy bash sshfs iproute2
RUN rm /sbin/iptables && ln -s /sbin/iptables-legacy /sbin/iptables
RUN rm /sbin/ip6tables && ln -s /sbin/ip6tables-legacy /sbin/ip6tables
# Download and install the telepresence binary
USER root
RUN curl -fL https://app.getambassador.io/download/tel2oss/releases/download/v2.18.0/telepresence-linux-amd64 -o telepresence
RUN chmod +x ./telepresence
And then I am running
> docker build . -t telepresence-cli
> docker run --network=host --cap-add=NET_ADMIN --device /dev/net/tun:/dev/net/tun -it --rm telepresence-cli
Inside the container
/ # ./telepresence
/bin/sh: ./telepresence: not found
/ # ./telepresence version
/bin/sh: ./telepresence: not found
Using an Ubuntu 22.04 base container I was able to run telepresence. My Dockerfile below.
# Dockerfile with telepresence and its prerequisites
FROM ubuntu:22.04
RUN apt-get update
RUN apt-get install -y curl ca-certificates sshfs
# Download and install the telepresence binary
RUN curl -fL https://app.getambassador.io/download/tel2oss/releases/download/v2.18.0/telepresence-linux-amd64 -o telepresence
RUN chmod +x ./telepresence