Subi um pequeno ambiente de desenvolvimento. São 2 containers:
- mysql (mysql:5.7)
- web (php:7.1-apache)
Minha dúvida está em um parâmetro de configuração do docker-compose.yml e Dockerfile, respectivamente:
- ports
- EXPOSE
Qual a diferença de ambos?
docker-compose.yml
version: "3.3"
services:
mysql:
container_name: mysql
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: SENHA_AQUI
MYSQL_DATABASE: webapp
MYSQL_USER: root
MYSQL_PASSWORD: senha_aqui
restart: always
ports:
- 3306:3306
web:
container_name: web
image: web_dev
build:
context: .
dockerfile: Dockerfile
volumes:
- ./htdocs/:/var/www
- ./apache/:/etc/apache2/sites-available/
working_dir: /var/www
depends_on:
- mysql
links:
- mysql
restart: always
ports:
- 80:80
Resolvi sub
Dockerfile:
FROM php:7.1-apache
MAINTAINER Fabio J L Ferreira <[email protected]>
RUN apt-get update && apt-get install -y curl unzip git npm && curl -sL https://deb.nodesource.com/setup_6.x | bash - && apt-get install -y nodejs
COPY php.ini /usr/local/etc/php/
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer
RUN rm -rf /var/lib/apt/lists/* /tmp/*