Answer the question
In order to leave comments, you need to log in
How to add an entry line to the end of the /etc/hosts file in a dockerfile?
Purpose of the task: it is necessary that instead of " 127.0.0.1:8080 " you can type http://test in the address bar , those http://127.0.0.1:8080=http://test
1. I write in /etc/apache2/ sites-available/000-default.conf is the following:
in the dockerfile, the line is responsible for this
ADD httpd.conf /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerName test
....
</VirtualHost>
RUN
echo "127.0.0.1 test" >> /etc/hosts \
&& a2enmod rewrite
echo "127.0.0.1 test" >> /etc/hosts
, it will be added (in this case, I restart Apache, and the container just gets corrupted - forced exit is performed - (Restarting Apache httpd web server: apache2Terminated - and the image has to reload.)) FROM php:7.3.4-apache
ADD httpd.conf /etc/apache2/sites-available/000-default.conf
ADD php.ini /usr/local/etc/php/php.ini
RUN apt-get update \
&& apt-get install -y git libzip-dev sqlite3 mc vim libicu-dev wget unzip\
&& pecl install xdebug-2.7.2 \
&& docker-php-ext-enable xdebug \
&& docker-php-ext-install zip pdo_mysql \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini\
&& echo bash -c "127.0.0.1 test" >> /etc/hosts \
&& a2enmod rewrite
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini\
&& echo bash -c "127.0.0.1 zend_web" >> /etc/hosts \
Answer the question
In order to leave comments, you need to log in
the command after && is executed only if the previous one completed without errors.
Since nothing worked for you after "docker-php-ext-install intl ", it means that there is a problem with it.
It's not clear why this is needed. Leave localhost and that's it. It is better to write the desired name on the machines from where you go to the web server in hosts. In your case, on the host where docker is deployed. You do not access the web from the docker, but from the client, which is on the main host, or on any other PC on this network (by writing pens in the hosts of each ip test) where ip is the address where the docker is running.
In documentation --add-host
...
--add-host="" : Add a line to /etc/hosts (host:IP)
...
Purpose of the task: it is necessary that instead of "127.0.0.1:8080" you can type http://test in the address bar, those http://127.0.0.1:8080=http://test
127.0.0.1 test
. This way you will solve the issue with the host name (test instead of IP 127.0.0.1) docker run --publish 80:8080 ...
- it seems to be written here: "bind the internal port of the container 8080 with the external port of the host machine 80" (in your case, it seems like both ports will be 80, both internal and external).Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question