this is my docker-compose.yml
site1:
build:
context: .
dockerfile: php/Dockerfile
image: alpine-php7.1
container_name: site1
restart: unless-stopped
tty: true
working_dir: /var/www
volumes:
- ../site1:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
depends_on:
- webserver
networks:
- dockernetwork
site2:
build:
context: .
dockerfile: php/Dockerfile
image: alpine-php7.1
container_name: site2
restart: unless-stopped
tty: true
working_dir: /var/www
volumes:
- ../site2:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
depends_on:
- webserver
networks:
- dockernetwork
#Nginx Service
webserver:
image: nginx:alpine
container_name: webserver
restart: unless-stopped
tty: true
ports:
- "80:80"
- "9000:9000"
volumes:
- ../site1:/var/www
- ../site2:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
networks:
- dockernetwork
And here is my Dockerfile
FROM php:7.1-fpm-alpine
# Install packages
RUN apk --no-cache add \
bash \
libzip-dev \
libpng-dev \
libjpeg-turbo-dev
# Install php extensions
RUN docker-php-ext-install zip
RUN docker-php-ext-configure gd --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install gd
RUN docker-php-ext-install pdo
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
I need to establish CURL communication between those two websites.
When I run docker exec -it site1 bash
and then
curl site2:9000
it gives me the following error curl: (56) Recv failure: Connection reset by peer
I also tried curl site2:80
and it gives me curl: (7) Failed to connect to site2 port 80: Connection refused
I have two PHP projects (two websites) and site1 requests data from site2 via CURL. When it's in production, it works fine as I curl to specific domains. But in the docker environment, I can't curl to site2 or site2.test since site1 is on a separate container.
Could you suggest a better docker-compose structure and some suggestions for the Dockerfile (what to use in FROM)