Cannot connect to php5.3-container

Hello!
It is my first exrerience with docker. I have a few containers: mysql, nginx, php7.1 and php 5.3. They are described into docker-composer.yml. If I configure my web-server through site conf-file for using php7.1, all works fine. But if I configure nginx for using php5.3, in this case I recieve error 111 Connection refused. I try to test connection to php53-container - port is closed. I can’t understand how to set it to open state

OS is Ubuntu 18.04

Please, help me! I had lost three days already…

It’s difficult to help you if we don’t see your compose file.

tekki, this is docker-compose.yml

Summary

version: ‘3’
services:
web:
env_file: ./.env
build:
context: ./configuration/nginx
dockerfile: Dockerfile
args:
NGINX_VERSION: {NGINX_VERSION} environment: HOST_USER_UID: {HOST_USER_UID}
HOST_USER_GID: {HOST_USER_GID} links: - php7 - php53 - mysql ports: - "{NGINX_PORT}:80"
volumes:
- ‘./code:/code:cached’
- "{NGINX_VHOST_DIR}:/etc/nginx/conf.d/" - './configuration/nginx/nginx.conf:/etc/nginx/nginx.conf' mysql: env_file: ./.env build: dockerfile: Dockerfile context: ./configuration/mysql args: MYSQL_VERSION: {MYSQL_VERSION}
volumes:
- ‘./db_data:/var/lib/mysql’
- ‘./shared:/shared’
#restart: always
environment:
MYSQL_VERSION: {MYSQL_VERSION} HOST_USER_UID: {HOST_USER_UID}
HOST_USER_GID: {HOST_USER_GID} MYSQL_ROOT_PASSWORD: {MYSQL_ROOT_PASSWORD}
ports:
- "{MYSQL_PORT}:3306" php7: env_file: ./.env build: context: ./configuration/php/php7 dockerfile: Dockerfile args: PHP7_VERSION: {PHP7_VERSION}
environment:
HOST_USER_UID: {HOST_USER_UID} HOST_USER_GID: {HOST_USER_GID}
links:
- mysql
expose:
- ‘9002’
volumes:
- ‘./code:/code:cached’
- ‘./configuration/php/www.conf:/usr/local/etc/php-fpm.d/zz-docker.conf’
- ‘./configuration/php/php7/fpm.conf:/usr/local/etc/php-fpm.conf’
- ‘./configuration/php/php7/ext:/usr/local/etc/php/conf.d’
- ‘./configuration/php/php7/php.ini:/usr/local/etc/php/php.ini’
working_dir: /code

Is the php7 container running or does it exit? You see it if you run docker-compose in the foreground (without the -d flag). If it is running: Do you use the correct address and port to connect to it?

Both containers (php7 and php53) work in the same time. They use network named docker-lemp_default. I inspected this network using docker network inspect docker-lemp_default command.
Sometimes after docker restarting (using docker-composer restart command) containers can change own ip-address. Therefore nginx configured for using service name instead of IP:

location … {

fastcgi_pass php53:9000;

}

If I use php7 instead of php53 in this confguration all works fine.

php53 is not started from the above compose file. Add it to this file or include both files in the same start command:

docker-compose -f first-composefile.yml -f second-composefile.yml ...

This will attach all containers to the same network.

tekki, I tried to write both services into docker-compose.yml, I tried to write only php7 and only php53 into docker-compose.yml. It has no any effect. All ports of php53 container are closed in any case. I used nmap utility to check ports of containers.
This is docker-compose.yml with both services:

Summary

version: ‘3’
services:
web:
env_file: ./.env
build:
context: ./configuration/nginx
dockerfile: Dockerfile
args:
NGINX_VERSION: {NGINX_VERSION} environment: HOST_USER_UID: {HOST_USER_UID}
HOST_USER_GID: {HOST_USER_GID} links: - php7 - php53 - mysql ports: - "{NGINX_PORT}:80"
volumes:
- ‘./code:/code:cached’
- "{NGINX_VHOST_DIR}:/etc/nginx/conf.d/" - './configuration/nginx/nginx.conf:/etc/nginx/nginx.conf' mysql: env_file: ./.env build: dockerfile: Dockerfile context: ./configuration/mysql args: MYSQL_VERSION: {MYSQL_VERSION}
volumes:
- ‘./db_data:/var/lib/mysql’
- ‘./shared:/shared’
#restart: always
environment:
MYSQL_VERSION: {MYSQL_VERSION} HOST_USER_UID: {HOST_USER_UID}
HOST_USER_GID: {HOST_USER_GID} MYSQL_ROOT_PASSWORD: {MYSQL_ROOT_PASSWORD}
ports:
- "{MYSQL_PORT}:3306" php7: env_file: ./.env build: context: ./configuration/php/php7 dockerfile: Dockerfile args: PHP7_VERSION: {PHP7_VERSION}
environment:
HOST_USER_UID: {HOST_USER_UID} HOST_USER_GID: {HOST_USER_GID}
links:
- mysql
expose:
- ‘9002’
volumes:
- ‘./code:/code:cached’
- ‘./configuration/php/www.conf:/usr/local/etc/php-fpm.d/zz-docker.conf’
- ‘./configuration/php/php7/fpm.conf:/usr/local/etc/php-fpm.conf’
- ‘./configuration/php/php7/ext:/usr/local/etc/php/conf.d’
- ‘./configuration/php/php7/php.ini:/usr/local/etc/php/php.ini’
working_dir: /code
php53:
env_file: ./.env
build:
context: ./configuration/php/php53
dockerfile: Dockerfile
environment:
HOST_USER_UID: {HOST_USER_UID} HOST_USER_GID: {HOST_USER_GID}
links:
- mysql
expose:
- ‘9002’
volumes:
- ‘./code:/code:cached’
- ‘./configuration/php/www.conf:/usr/local/etc/php-fpm.d/zz-docker.conf’
- ‘./configuration/php/php53/ext:/usr/local/etc/php/conf.d’
- ‘./configuration/php/php53/php.ini:/usr/local/etc/php/php.ini’
- ‘./configuration/php/php53/php-cli.ini:/usr/local/etc/php/php-cli.ini’
working_dir: /code

The command docker network inspect docker-lemp_default shows that all containers belong to the same network

I forgot to say something. In other computer (ubuntu 18.04 like my computer) this php53 container has an opened port. In its case docker-compose.yml describes only three services: php7, web, mysql. However the php53 container works also. I tried to copy docker-compose.yml and Dockerfile-files from that computer to resolve my problem