Docker Community Forums

Share and learn in the Docker community.

How to use telnet in docker container?

(Anacondaonline) #1

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 ?

(Think) #2

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.

(Anacondaonline) #3

How do you user netcat for an IP and port ?

(Think) #4

(Anacondaonline) #5

okay . I tested it .

$nc 389

I get message

bash: nc: command not found

what is other workaround ?

(Think) #6

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

(Anacondaonline) #7

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


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

(Think) #8

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.

(Anacondaonline) #9

How do you do that ?

(Think) #10

Get Started, Part 2: Containers | Docker Documentation

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.

(Hclung) #11

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?

(Rmsys) #12

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


curl container-name:port