There is such an image for quick LEMP deployment.

version: '2' services: nginx: image: evild/alpine-nginx:1.9.15-openssl container_name: lemp_nginx restart: always links: - php volumes: - ./public:/var/www/html/:ro - ./nginx/conf/nginx.conf:/etc/nginx/conf/nginx.conf:ro - ./nginx/conf.d:/etc/nginx/conf.d:ro ports: - 80:80 - 443:443 php: image: evild/alpine-php:7.0.6 container_name: lemp_php restart: always volumes: - ./html:/var/www/html depends_on: - db links: - db environment: - DB_NAME=lemp_bdd - TABLE_PREFIX=lemp_ - DB_HOST=lemp - DB_PASSWORD=password db: image: mariadb:latest container_name: lemp_mariadb restart: always volumes: - db-data:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=password volumes: db-data: driver: local 

There is a file docker-compose yml, the description above.

Such moments are not clear:

1. Image of nginx

 volumes: - ./public:/var/www/html/:ro - ./nginx/conf/nginx.conf:/etc/nginx/conf/nginx.conf:ro - ./nginx/conf.d:/etc/nginx/conf.d:ro ports: - 80:80 - 443:443 

1.1 Sounds at the end of the lines : ro - what does this mean?

1.2 Do you need port 443?

2. Php Image

 volumes: - ./public:/var/www/html environment: - DB_NAME=lemp_bdd - TABLE_PREFIX=lemp_ - DB_HOST=lemp - DB_PASSWORD=password 2.1 Зачем в образе php указывать еще раз корень ./public:/var/www/html 2.2 Почему переменные базы лежат в образе php, а не db? 2.3 Переменные по базе(DB_NAME, TABLE_PREFIX и т.д) - это уже установленные в образе? То есть чтобы поменять имя базы и прочее, мне нужно залазить внутрь контейнера? Или эти данные будут браться для создания базы с такими параметрами? 2.4 Почему - DB_HOST=lemp, обычно localhost или ip или это внутри контейнера в hosts прописано 127.0.0.1 lemp? 

2.db db

 volumes: - db-data:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=password 

3.1 - db-data: / var / lib / mysql - what is this line for?

3.2 - - MYSQL_ROOT_PASSWORD = password is the root password, but in the php image there is no DB_USERNAME =, that is, you need to go into the container again and create a user?

 volumes: db-data: driver: local 

What is this block for?

    1 answer 1

    1.1 Sounds at the end of the lines: ro - what does this mean?

    Read-only: the container cannot change files at mount points, but can read them. This is good practice and can protect against some (but not very likely) attacks.

    1.2 Do you need port 443?

    HTTPS encrypts the entire data stream completely, and thus is a fundamentally different protocol (even though exactly the same data is transmitted inside), so it needs to be processed on a separate port. The default for HTTPS is 443.

    2.2 Why are the database variables in the image of php, and not db?

    Because it is not "database variables", but data required for authorization in the database

    2.4 Why is DB_HOST = lemp, usually localhost or ip, or is it 127.0.0.1 lemp registered in a container in the container?

    Because 127.0.0.1 in a container is the container itself, and the base lies in a different container / on another machine, which (th) can be referred to as lemp (perhaps, here is just a naming error, and meant lemp_mariadb)

    3.1 - db-data: / var / lib / mysql - what is this line for?

    "mount the db-data directory flush with docker-compose.yml as / var / lib / mysql inside the container"

    • Tell me how to work with the base? the base should be inside the container, then how to roll migration? - ruslik
    • @ruslik and does when rolling migrations there is a difference where the base is located? - etki
    • So, where is the base located inside the container or not? - ruslik
    • @ruslik you have declared container db in docker-compose - obviously, that is it - etki