How to use telnet in docker container?

I have a docker image . I’m into the container bash now. Is there any way to use telnet or alternative in container ?

when I try to run telnet <some_ip> 389 … I get telnet command not found.

What could be a workaround ?

depending on your image you are using, it may contain a telnet client or not. Most images do not contain telnet clients. But if you are fine with netcat, then use this, because this is more likely to be already installed.
if you insist on telnet and have for example an ubuntu image, then just execute apt-get update && apt-get install telnet.

How do you user netcat for an IP and port ?

http://linux.byexamples.com/archives/258/when-netcat-act-as-telnet-client-it-becomes-better/

okay . I tested it .

$nc xx.xx.xxx.xxx 389

I get message

bash: nc: command not found

what is other workaround ?

could you post your Dockerfile? you need to install either telnet or netcat if you want to use it. :slight_smile:

Here is my docker file

$docker volume create --name tuleap-data
$sudo docker run -d -e VIRTUAL_HOST=localhost -p 80:80 -p 443:443 -p 22:22 -v tuleap-data-rnd:/data enalean/tuleap-aio

source: https://www.tuleap.org/get-started/deploy-tuleap-docker-container

Let me know if are able to use telnet or netcat in the container ?

centos:6 does not contain telnet…but you could derive an image out of the image you are using and just add a yum install telnet to it.

How do you do that ?

Get Started, Part 2: Containers | Docker Documentationhttps://docs.docker.com/get-started/part2/#your-new-development-environment


1: Orientation 2: Containers 3: Services 4: Swarms 5: Stacks 6: Deploy your app Prerequisites Install Docker version 1.13 or higher. Read the orientation in Part 1.

does this help you? it is a rather basic question, so I would suggest to first run through the basic tutorial.

I have a similar problem. When I start Docker, I am in a completely different space. The IP would be changed, and I get cut from my original network. Could I control the IP address, or change the configuration so that I can connect to other systems on my original network?

Hey anacondaonline!

I tried to all this options too: telnet, dig, nc, netcat and nothing works… the commands bash in docker process are very limiteds…

But, I got with

curl ip:port

or

curl container-name:port

1 Like