For development I need to ‘connect’ with the ‘file_get_contents()’ php command from 1 container to another.
I’m using a default ngnix container from ‘jwilder/nginx-proxy:alpine’ with this configuration:
`
version: "3.7"
services:
nginx-proxy:
container_name: nginx-proxy
image: jwilder/nginx-proxy:alpine
ports:
- 80:80
- 443:443
volumes:
- ./certs:/etc/nginx/certs:ro
- /var/run/docker.sock:/tmp/docker.sock:ro
restart: always
networks:
default:
external:
name: nginx-proxy
`
The 2 php containers are configured the same with this setup
version: '3'
services:
apache:
image: httpd:2.4.41
networks:
- www
- default
volumes:
- ./docker/config/apache/httpd.conf:/usr/local/apache2/conf/httpd.conf:ro
- ./docker/config/apache/httpd-vhosts.conf:/usr/local/apache2/conf/extra/httpd-vhosts.conf:ro
- ./src:/var/data/www:rw
php:
networks:
- www
build:
context: .
dockerfile: ./docker/images/php/7.3/Dockerfile
environment:
ENABLE_XDEBUG: $ENABLE_XDEBUG
volumes:
# Mount point for project files
- ./src:/var/data/www:rw
# xdebug output
- ./docker/data/xdebug:/var/data/xdebug:rw
# Load PHP ini files
- ./docker/config/php/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini:ro
- ./docker/config/php/php.ini:/usr/local/etc/php/conf.d/php.ini:ro
# Load PHP-FPM config files
- ./docker/config/php-fpm/zz-docker.conf:/usr/local/etc/php-fpm.d/zz-docker.conf:ro
# bind ssh keys to be able to download private repos from github
- ~/.ssh/id_rsa:/tmp/.ssh/id_rsa:ro
- ~/.ssh/id_rsa.pub:/tmp/.ssh/id_rsa.pub:ro
working_dir: /var/data/www
networks:
www:
default:
external:
name: nginx-proxy
I have tries to add
extra_hosts:
- “url_for_file_get_contents_command:172.30.0.4”
so that the hosts is added in the /etc/hosts config. This did not work.
Help please!