I have successfully set up Docker, Apache2, PHP in separate containers. I can access my website via http://localhost:8080.
The problem I have is to do with /etc/hosts file (I think). Let’s take a look at my docker-compose file:
apache2: build: context: ./apache2/ dockerfile: Dockerfile container_name: apache2 image: httpd:2.4.39-alpine ports: - 8080:80 volumes: - ../:/srv/app extra_hosts: - "custom-website-name.local:127.0.0.1"
As you can see I did add the extra host in there and it even appears in /etc/hosts file in the container. However, no matter what I do and what changes do I make(manually on the LIVE container and in config) I can’t force my setup to recognize that new host.
I also have vhost config in place:
LoadModule deflate_module /usr/local/apache2/modules/mod_deflate.so LoadModule proxy_module /usr/local/apache2/modules/mod_proxy.so LoadModule proxy_fcgi_module /usr/local/apache2/modules/mod_proxy_fcgi.so <VirtualHost *:80> ServerName www.custom-website-name.local ServerAlias custom-website-name.local # Proxy .php requests to port 9000 of the php-fpm container ProxyPassMatch ^/(.*.php(/.*)?)$ fcgi://webapp:9000/srv/app/public/$1 DocumentRoot /srv/app/public <Directory /srv/app/public> DirectoryIndex index.php Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> # Send apache logs to stdout and stderr CustomLog /proc/self/fd/1 common ErrorLog /proc/self/fd/2 </VirtualHost>
Which is copied into the config. It all seems to be not enough at this point I can access my website only via
http://custom-website-name.local:8080 gives me
This site can’t be reached which means that new name was not resolved.
The question of course is: what am I missing? I have no clue what else I can try (and I did try the whole bunch of things).
I did add an entry to local (non docker)
/etc/hosts as well – did not help.