1

I want to download a public github project and run a project file through internal php server, through docker.

This is my file so far:

FROM php:7.2-cli
RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y git
RUN git clone https://github.com/mygit src
WORKDIR src

CMD ["php", "-S", "0.0.0.0:80", "-t", "/src/src/examples/image.php"]

The process does not show up in docker ps when I run:

docker build -t myimage .
docker run -d -p 8080:8080 myimage
Douma
  • 2,682
  • 14
  • 23
  • Run `docker ps -a` to obtain a list with running and stopped containers, then find the container id you wish to debug, execute `docker logs containerId` and provide the output in your original post. – leopal Apr 17 '19 at 05:13
  • docker logs 86ac2cbd6f11 [Tue Apr 16 22:36:31 2019] 172.17.0.1:59284 [200]: / [Tue Apr 16 22:41:30 2019] 172.17.0.1:59288 [200]: / [Tue Apr 16 22:41:30 2019] 172.17.0.1:59292 [404]: /favicon.ico - No such file or directory [Tue Apr 16 22:41:37 2019] 172.17.0.1:59290 [200]: / – Douma Apr 17 '19 at 06:12
  • Strange,now when I run `docker run -d -p 8081:8081 myimage` it seems to work, docker ps shows the process, but now I got no information sent error. Docker logs is empty now. – Douma Apr 17 '19 at 06:19
  • Can you share your github link project so I can tell you exactly what your issue is? 8080 may be already used in your docker host.. – leopal Apr 17 '19 at 06:42
  • https://github.com/douma/langtons-ant. I try to run CMD ["php", "-S", "0.0.0.0:80", "/src/src/examples/image.php"] – Douma Apr 17 '19 at 08:28

1 Answers1

0

Try with this Dockerfile:

FROM php:7.2-cli
RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y git
RUN git clone https://github.com/douma/langtons-ant src
WORKDIR src
ENTRYPOINT ["php"]
CMD ["-S", "0.0.0.0:8080","/src/src/examples/image.php"]

Note I don't know php but checking your github project's readme I think you do not need the -t argument.

I also added ENTRYPOINT command to make your Dockerfile clearer. For differences check this.

The build and run commands should be the same as these you posted.

docker build -t myimage .
docker run -d -p 8080:8080 myimage
leopal
  • 4,711
  • 1
  • 25
  • 35