Skip to content

Instantly share code, notes, and snippets.

@ribafs
Created December 14, 2020 02:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ribafs/3410e9339273b85d15f3e89be7a2edcc to your computer and use it in GitHub Desktop.
Save ribafs/3410e9339273b85d15f3e89be7a2edcc to your computer and use it in GitHub Desktop.
Meu Dockerfile
FROM ribafs/ubuntu-maria
ENV MYSQL_ROOT_PASSWORD root
ENV MYSQL_ROOT_DATABASE testes
RUN apt-get update
EXPOSE 3306
ADD ["script.sql", "/tmp/script.sql"] # Cria o banco e muda a senha para vazia
CMD ["start-mysql"]
RUN mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "CREATE DATABASE testes"
RUN mysql -uroot -p${MYSQL_ROOT_PASSWORD} -D testes < /tmp/script.sql
Meu docker-compose.yml
version: "3.3"
networks:
web:
driver: bridge
services:
web:
image: ribafs/ubuntu-php
container_name: web
build:
context: web
dockerfile: Dockerfile
ports: # <Port exposed> : < MySQL Port running inside container>
- "80:80"
- "443:443"
expose: # Opens port 3306 on the container
- "80"
- "443"
volumes:
- ".:/var/www/html/"
environment:
- APP_DEBUG=true
read_only: false
privileged: true
links:
- mariadb
networks:
- web
command: 'bash'
mariadb:
image: ribafs/ubuntu-maria
command: --default-authentication-plugin=mysql_native_password
container_name: maria
build:
context: maria
dockerfile: Dockerfile
restart: always
ports:
- "3306:3306"
command: --init-file maria/script.sql
expose: # Opens port 3306 on the container
- "3306"
volumes:
- ./maria/script.sql:/data/application/init.sql
- persistent:/var/lib/mysql/
read_only: false
privileged: true
environment:
MYSQL_ROOT_PASSWORD: 'root'
MYSQL_DATABASE: 'testes'
MYSQL_PORT: 3306
networks:
- web
command: 'bash'
tty: true
volumes:
persistent:
Quando executo
docker run web bash
Ele para na linha
RUN mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "CREATE DATABASE testes"
Também não inicia o mysql
Mesmo eu comentando as 2 últimas linhas ainda não inicia.
Agradeço qualquer ajuda.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment