1
0

I am unable to get the VSCode debugger to work with PHP running in a podman container. I was able to set this up using Docker by following these steps...

  1. Create php.dockerfile (Dockerfile)
  2. Create php.ini
  3. Add VSCode debugging launch configuration to VSCode settings.json
  4. Create container in Docker
  5. Start container
  6. Open workspace folder of the PHP script in VSCode
  7. Add breakpoints in the PHP script in VSCode
  8. Start Debugger in VSCode
  9. Run PHP script in docker container which will trigger the debugger in VSCode

I believe it is due to some networking setup with Podman which requires additional configuring for the debugger attach itself to the PHP script in the Podman container.

Any help will be most appreciated.

Dockerfile php.dockerfile

FROM docker.io/php:cli

# Install xdebug for nicer error messages
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug

php.ini

[PHP]

; xdebug settings for debugging
zend_extension=xdebug
xdebug.mode=debug
xdebug.client_host=xdebug://gateway

VSCode debugger launch config...

"launch": {
        "configurations": [
            {
                "name": "PHP (Container): Terminal",
                "type": "php",
                "request": "launch",
                "pathMappings": {
                    "/usr/src/app/": "${workspaceFolder}"
                }
            }
        ]
    },

Terminal commands to set this all up and run the script

$ docker image build -t my-php-image -f php.dockerfile .
$ docker container create --name my-container -v ./app/:/usr/src/app/ -v .:/usr/local/etc/php/ -w /usr/src/app/ -it my-php-image
$ docker container start my-container
$ docker container exec -it my-container php -d xdebug.start_with_request=yes test.php
2
15
submitted 3 months ago by mac@programming.dev to c/podman@programming.dev
3
18
submitted 3 months ago by mac@programming.dev to c/podman@programming.dev
4
6
submitted 6 months ago by mac@programming.dev to c/podman@programming.dev
5
1
submitted 7 months ago by mac@programming.dev to c/podman@programming.dev
6
1
Podman v4.8 released! (blog.podman.io)
submitted 7 months ago by mac@programming.dev to c/podman@programming.dev
7
1

Is it possible to run a alpine image to run an executable that is inside a volume without creating a new image? In Podman Desktop, I placed the following values in these fields when running the alpine image into a new container.

Command

/bin/sh -c /server/application

Volumes

~/Documents/server-data:/server

Ports

8080:8080

However I always get this error in my container logs. I think it could be due to the fact the container does not have permission to execute /server/application?

/bin/sh: /server/application: not found

8
1

Is there way on windows to add an alias for commands in powershell and command prompt?

I want to make it so when I enter docker it will execute podman

I was able to achieve this easily on Linux to were I can always enter docker and it will execute podman, even if I closed the terminal window or rebooted my machine. It was a permanent alias redirect, not a temporary one.

Can this be done on Windows for powershell and command prompt?

9
1

In order for me to get Podman to run on windows, I need to enter podman machine start in powershell every time I boot up Windows. Is there a way to have podman running and ready to go when I boot into Windows?

Podman

83 readers
1 users here now

founded 9 months ago
MODERATORS