0

I've a docker container running on my Linux host.

root@eve-ng-6:~# docker ps
CONTAINER ID   IMAGE                             COMMAND            CREATED       STATUS       PORTS     NAMES
ea25d3afa65d   ios-xr/xrd-control-plane:latest   "/usr/sbin/init"   2 hours ago   Up 2 hours             3e2241f3-f914-456a-891f-671c42fafef3-0-5
root@eve-ng-6:~#
root@eve-ng-6:~# systemctl status docker.service
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/docker.service.d
             └─http-proxy.conf, tcp-sock.conf
     Active: active (running) since Thu 2025-05-29 13:12:13 UTC; 3min 54s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 1265607 (dockerd)
      Tasks: 19
     Memory: 38.5M
        CPU: 1.258s
     CGroup: /system.slice/docker.service
             └─1265607 /usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:4243
root@eve-ng-6:~# ps -ef | grep 1265607
root     1265607       1  0 13:12 ?        00:00:00 /usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:4243
root     1271097  674199  0 13:16 pts/3    00:00:00 grep --color=auto 1265607
root@eve-ng-6:~#

Is there a way to connect to its primary process using an URL like docker://127.0.0.1:4243/<container id> ? Thanks.

Edit: based on comment received, I'd ask whether it is possible to redirect stdin/stdout of docker attach <> command to a tcp socket. Searching for it I found docker attach

You can't redirect the standard input of a docker attach command while attaching to a TTY-enabled container (using the -i and -t options).

Does this mean that it is actually not feasible to do that ?

1
  • 1
    what do you mean with "connect to a process"? Commented May 29 at 13:48

1 Answer 1

2

Your docker ps command shows you have only one container running, and it has the ID ea25d3afa65d, uses the Image ios-xr/xrd-control-plane:latest, but has no Ports mapped.

Your question asks if it's possible to connect to a TCP port on the host and have the dockerd process tunnel/bridge your connection to a port inside the container where the software is listening for connections.

Unfortunately, the answer is No. The reason you can't is revealed in the empty PORT column in the output of docker ps command. When the container was launched, nothing defined the connection mapping/tunneling between a port inside the container and a port on the host, so no such mapping/tunnel was created by dockerd.

The container might have started a process that's listening for connections, but nothing told dockerd to make that port available for connections on the host (or from other hosts to the host).

The name on the container's image leads me to sites that suggest this is an emulator or training tool for Cisco IOS network devices. I think you'll need to go back to the documentation that told you how to install the container and see if there are steps for building the container or configuring/launching the container that you overlooked.

3
  • Yes, it is a docker image for a Cisco IOS-XR network device. I use a web-based application to manage networking labs. The php code inside it calls docker create and docker start to create & start a container. Then, to access it, php code defines a sort of URL docker://127.0.0.1:4243/<container id>. However I don't know how to use it to access the running container :-( Commented May 30 at 8:56
  • Then you need to consult the documentation for the PHP module that translates URLs that begin docker:// into calls to the Docker API (perhaps some equivalent to docker exec ...). Docker-PHP appears to be one, but it hasn't been updated in almost 7 years. Commented May 30 at 11:57
  • To be clear: I'd redirect stdin/stdout of docker container's primary process (i.e. the process within the container that runs the entrypoint /sbin/init) on a host's tcp port. Then I'd connect to it using telnet to that port. Commented May 30 at 13:18

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.