Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access a docker containers own localhost inside that container -- php apache

I am trying to access the http://localhost/ or http://127.0.0.1 from inside the docker container itself. I can ping localhost when I am inside the running container:

$ sudo docker exec -i -t 045ff7f4755b /bin/bash
$ ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.108 ms

But, I get an error when I try

$ curl 127.0.0.1/api.php
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused

Here is my dockerfile:

FROM php:7.1.0-apache
RUN pecl install xdebug-2.5.0 \
    && docker-php-ext-enable xdebug

RUN mkdir /opt/framework
COPY . /opt/framework
COPY . /var/www/html/

WORKDIR /opt/framework
ENTRYPOINT ["docker-php-entrypoint"]

The endgame here, is to be able to run codeception (an acceptance tester) inside that container and for everything to be contained inside that container. I am also open to the idea that I may be approaching this entirely wrong. I am new to docker, and am not sure the best way to get my desired result.

like image 417
Apollo Avatar asked Mar 22 '26 16:03

Apollo


1 Answers

The problem is that you are adding the same ENTRYPOINT from the base image, and that is messing everything up, if you remove that line, your problem is solved.

like image 160
Timmy McCormack Avatar answered Mar 24 '26 08:03

Timmy McCormack



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!