Answer the question
In order to leave comments, you need to log in
Do I need to create a dockerfile when using three docker-compose images?
taking the first steps in learning docker and docker-compose. It's not entirely clear whether you need to write a dockerfile if you describe 3 or more images in docker-compose? If you don’t need to write what name and path you need to specify in docker-compose
, for example Laravel (there are more than 3 images here)
nginx:
dockerfile: docker/nginx.docker the path is specified, and it will appear from where, if I have, for example, UBUNTU and I installed docker and docker-compose there. It turns out that it was created through a dockerfile, or it is written like this docker/nginx.docker automatically uploads an image from dockerhub and I need to create a dockerfile.
version: '3'
services:
nginx:
build:
context: ./
dockerfile: docker/nginx.docker
volumes:
- ./:/var/www
ports:
- "8080:80"
depends_on:
- php-fpm
php-fpm:
build:
context: ./
dockerfile: docker/php-fpm.docker
volumes:
- ./:/var/www
depends_on:
- mysql
- redis
environment:
- "DB_PORT=3306"
- "DB_HOST=mysql"
- "REDIS_PORT=6379"
- "REDIS_HOST=redis"
php-cli:
build:
context: ./
dockerfile: docker/php-cli.docker
volumes:
- ./:/var/www
depends_on:
- mysql
- redis
environment:
- "DB_PORT=3306"
- "DB_HOST=mysql"
- "REDIS_PORT=6379"
- "REDIS_HOST=redis"
tty: true
mysql:
image: mysql:5.7
volumes:
- ./storage/docker/mysql:/var/lib/mysql
environment:
- "MYSQL_ROOT_PASSWORD=secret"
- "MYSQL_USER=app"
- "MYSQL_PASSWORD=secret"
- "MYSQL_DATABASE=app"
ports:
- "33061:3306"
redis:
image: redis:3.0
ports:
- "6379:6379"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question