NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
PhpED and dockers


Joined: 27 Nov 2009
Posts: 98
Reply with quote
I have PHP running in a docker. I can access it by using docker exec -it <container-id> /bin/sh. It also contains a webserver (caddy) which is exposed on 8080/8443.

How can I use PhpED to debug the PHP?

Thanks
View user's profileFind all posts by NotionCommotionSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
You can debug php inside docker if you can ssh into the container. In this case treat it as a remote server.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 27 Nov 2009
Posts: 98
Reply with quote
Thanks dmitri,

The docker in question is for api-platform https://api-platform.com/docs/distribution/#using-the-api-platform-distribution-recommended. I was unsuccessful attempting to ssh into it.

Code:
$ docker ps
CONTAINER ID   IMAGE                           COMMAND                  CREATED       STATUS                 PORTS                                                                                                                               NAMES
36d5d7f3f2ea   multi-tenanacy-skeleton_caddy   "caddy run --config …"   9 days ago    Up 9 days              2019/tcp, 0.0.0.0:8080->80/tcp, :::8080->80/tcp, 0.0.0.0:8443->443/tcp, 0.0.0.0:8443->443/udp, :::8443->443/tcp, :::8443->443/udp   multi-tenanacy-skeleton_caddy_1
7cc9567859e1   multi-tenanacy-skeleton_php     "docker-entrypoint p…"   9 days ago    Up 9 days (healthy)    9000/tcp                                                                                                                            multi-tenanacy-skeleton_php_1
ec46716113f5   multi-tenanacy-skeleton_pwa     "docker-entrypoint.s…"   9 days ago    Up 9 days              3000/tcp                                                                                                                            multi-tenanacy-skeleton_pwa_1
3a8ee6eb47f1   postgres:13-alpine              "docker-entrypoint.s…"   9 days ago    Up 9 days              0.0.0.0:5433->5432/tcp, :::5433->5432/tcp                                                                                           multi-tenanacy-skeleton_database_1

$ docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 7cc9567859e1
172.28.0.3

$ ssh root@172.28.0.3
ssh: connect to host 172.28.0.3 port 22: Connection refused

$ ssh root@172.28.0.3 -p9000
ssh: connect to host 172.28.0.3 port 9000: Connection refused
$


I am, however, able to access it using docker. uname -r tells me I am running alpine but for unknown reasons cat /proc/version reports redhat. I expect that the docker is not running a ssh server and added it but the docker doesn't seem to recognize rc-update.

Code:
$ docker exec -it 7cc9567859e1 /bin/sh

/srv/api # whoami
root

/srv/api # uname -r
4.18.0-305.17.1.el8_4.x86_64
/srv/api # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.15.0
PRETTY_NAME="Alpine Linux v3.15"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"

/srv/api # cat /proc/version
Linux version 4.18.0-305.17.1.el8_4.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.4.1 20200928 (Red Hat 8.4.1-1) (GCC)) #1 SMP Wed Sep 8 14:00:07 UTC 2021

/srv/api # ifconfig
eth0      Link encap:Ethernet  HWaddr 02:42:AC:1C:00:03
          inet addr:172.28.0.3  Bcast:172.28.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:194763 errors:0 dropped:0 overruns:0 frame:0
          TX packets:194981 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:45135017 (43.0 MiB)  TX bytes:46996993 (44.8 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:3536 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3536 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:219200 (214.0 KiB)  TX bytes:219200 (214.0 KiB)

/srv/api # apk search openssh
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.15/main: No such file or directory
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.15/community: No such file or directory

/srv/api # apk add openssh
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
(1/8) Installing openssh-keygen (8.8_p1-r1)
(2/8) Installing libedit (20210910.3.1-r0)
(3/8) Installing openssh-client-common (8.8_p1-r1)
(4/8) Installing openssh-client-default (8.8_p1-r1)
(5/8) Installing openssh-sftp-server (8.8_p1-r1)
(6/8) Installing openssh-server-common (8.8_p1-r1)
(7/8) Installing openssh-server (8.8_p1-r1)
(8/8) Installing openssh (8.8_p1-r1)
Executing busybox-1.34.1-r3.trigger
OK: 78 MiB in 61 packages

/srv/api # apk search openssh
perl-net-openssh-0.80-r0
openssh-sftp-server-8.8_p1-r1
openssh-keysign-8.8_p1-r1
openssh-client-krb5-8.8_p1-r1
openssh-client-default-8.8_p1-r1
openssh-keygen-8.8_p1-r1
aconf-mod-openssh-0.8.1-r1
openssh-client-yash-completion-2.52-r0
openssh-client-common-8.8_p1-r1
perl-net-openssh-doc-0.80-r0
openssh-server-common-8.8_p1-r1
openssh-server-pam-8.8_p1-r1
acf-openssh-0.11.2-r2
openssh-doc-8.8_p1-r1
openssh-server-krb5-8.8_p1-r1
openssh-8.8_p1-r1
openssh-server-8.8_p1-r1
openssh-dbg-8.8_p1-r1

/srv/api # rc-update add sshd
/bin/sh: rc-update: not found

/srv/api #


Is there another way to use PHPed to debug it? Maybe somehow using docker exec -it 7cc9567859e1 /bin/sh?

Thanks
View user's profileFind all posts by NotionCommotionSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Basically "debug" means a) adding certain debugger request that contains connection point to reach the IDE and b) providing network connectivity to that point.
Debugger is looking for request in cookie, environment, command line arguments, GET query variable and POST variable. See examples here http://www.nusphere.com/kb/technicalfaq/faq_dbg_related.htm
Note that it includes either real host name as a connection point or "clienthost" construct that tells Debugger to look into REMOTE_ADDRESS variable and try to connect back to it.
It's easy to use SSH port forwarding and "localhost:7869" as a connection point which SSH would forward back to the IDE host.
So it's not only about reaching file system or shell in the docker, it's more about connectivity, but if you can connect them in another way, like through NAT(s) or with special IPTable entries on the hosting OS, it may work too.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
PhpED and dockers
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic