skip to Main Content

I have a bash script and a php script.

——–EDIT——–
I SOLVED IT, I AM JUST STUPID, I WROTE MY ANSWER BELOW.

(I can put code screenshots if you want.)

MY DOCKERFILE:

ARG VERSION=latest
FROM ubuntu:bionic
RUN apt-get -y update && apt-get -y upgrade
COPY ./resources/ start.sh /sandbox/
WORKDIR /sandbox/
ENTRYPOINT ["sh","start.sh"]

I want to execute them in a docker container as i said in the title.

The ‘entry point’ of the docker container is the bash script.

Inside the bash script i have a line

php PHP_SCRIPT.php

But when i execute, it gives me the error:

PHP_SCRIPT.php: php: not found

or something like that

i saw that the php command usually resides in ‘/usr/bin/php’,
but i tried to run the command ‘which php’ in the docker container and the result was ‘/usr/local/bin/php’

Maybe i am calling the php command wrong?

But the result that i want is to run a php script INSIDE a bash script that starts when i start the docker container.

3

Answers


  1. Chosen as BEST ANSWER

    And i would get the "php not found error" because i didnt install php to the docker container.

    So, I tried writing in the dockerfile

    RUN apt-get php-cli (i also tried with php:cli and seemed to have same effect),

    to try to install php to container, but when i would start container it would seem like it would freeze and not do anything.

    Apparenty, it doesnt 'freeze', but i only had to wait for the php to update in the container. :D


  2. You are using the docker image FROM ubuntu:bionic which does not have PHP installed by default. Try FROM php (or one of the many tags available) instead.

    Login or Signup to reply.
  3. the problem is that PHP is not installed in your container
    To do this, you can use your official PHP image
    https://hub.docker.com/_/php

    FROM php:7.4-cli
    
    ARG VERSION=latest
    RUN apt-get -y update && apt-get -y upgrade
    COPY ./resources/ start.sh /sandbox/
    WORKDIR /sandbox/
    ENTRYPOINT ["sh","start.sh"]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search