I created a Symfony environment with Docker. I then included this file in my web project (skeleton website). But when I try to access my base.html.twig page located in a main folder from the controller, I get this error:
Unable to find template "main/base.html.twig" (looked into: /var/www/templates, /var/www/vendor/symfony/twig-bridge/Resources/views/Form).
How can I solve the problem? I have version 5 of Symfony.
Here is the content of my docker-compose file:
version: '3'
services:
php:
container_name: "php-fpm"
build:
context: ./php
environment:
- APP_ENV=${APP_ENV}
- APP_SECRET=${APP_SECRET}
volumes:
- ${APP_FOLDER}:/var/www
networks:
- dev
nginx:
container_name: "nginx"
build:
context: ./nginx
volumes:
- ${APP_FOLDER}:/var/www
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./logs:/var/log/nginx/
depends_on:
- php
ports:
- "80:80"
networks:
- dev
db:
image: mysql
container_name: "db"
restart: always
volumes:
- db-data:/var/lib/mysql
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
networks:
- dev
phpmyadmin:
image: phpmyadmin
container_name: "phpmyadmin"
restart: always
depends_on:
- db
ports:
- 8080:80
environment:
PMA_HOST: db
networks:
- dev
networks:
dev:
volumes:
db-data:
Your Docker Compose file needs to link local folders with Docker folders.
#docker-compose example
version: "3"
services:
web:
build: .
ports:
- "8080:80"
volumes:
- .:/var/www # Map local folder to Docker
Related
Context
Our solution send emailing campaign, and some email provider makes temporary blacklist because we used inexistant email addresses (they may be created/imported by any user)
Solution
I try to implement a email checker based on https://www.codexworld.com/verify-email-address-check-if-real-exists-domain-php/
Problem
From my local computer, this script works (when my IP is not temporary blacklisted) but from my Docker Container stream_socket_client or even telnet always times out.
As I see, MX servers always time out non verified requester but how can I make it work from my docker container?
I've no specific docker configuration for the port 25.
Thank you
docker-compose.yml
# Base docker-compose file to run required services: Adminer, MySQL, and Redis
version: '3.7'
services:
adminer:
image: adminer:latest
ports:
- "8080:8080"
database:
image: mysql:8.0
volumes:
- db_data:/var/lib/mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
cap_add: [ SYS_NICE ] # https://github.com/docker-library/mysql/issues/303
command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_general_ci', '--lower_case_table_names=1']
redis:
image: redis:alpine
expose:
- "6379"
redisinsight:
image: redislabs/redisinsight
ports:
- "8081:8001"
reverse-proxy:
image: nginx:alpine
depends_on:
- backend
- frontend
volumes:
- ./../../../backend/infra/etc/nginx/dev.conf:/etc/nginx/nginx.conf
ports:
- "80:80"
backend:
build:
context: ./../..
dockerfile: container/dev/backend.dockerfile
expose:
- "80"
volumes:
- {...}
depends_on:
- database
frontend:
build:
context: ./../..
dockerfile: container/dev/frontend.dockerfile
expose:
- "3000"
volumes:
- {...}
tty: true # required to keep yarn running (https://stackoverflow.com/a/61050994)
volumes:
# Contains the database's data
db_data: {}
# Base docker-compose file to run required services: Adminer, MySQL, and Redis
version: '3.7'
services:
adminer:
image: adminer:latest
ports:
- "8080:8080"
database:
image: mysql:8.0
volumes:
- db_data:/var/lib/mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
cap_add: [ SYS_NICE ] # https://github.com/docker-library/mysql/issues/303
command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_general_ci', '--lower_case_table_names=1']
redis:
image: redis:alpine
expose:
- "6379"
redisinsight:
image: redislabs/redisinsight
ports:
- "8081:8001"
reverse-proxy:
image: nginx:alpine
depends_on:
- backend
- frontend
volumes:
- ./../../../backend/infra/etc/nginx/dev.conf:/etc/nginx/nginx.conf
ports:
- "80:80"
backend:
build:
context: ./../..
dockerfile: container/dev/backend.dockerfile
expose:
- "80"
volumes:
- {...}
depends_on:
- database
frontend:
build:
context: ./../..
dockerfile: container/dev/frontend.dockerfile
expose:
- "3000"
volumes:
- {...}
tty: true # required to keep yarn running (https://stackoverflow.com/a/61050994)
volumes:
# Contains the database's data
db_data: {}
backend.dockerfile is an ubuntu with git, mysql-client, php
i've installed docker (windows 10) with wsl2 (ubuntu distro) and added my docker-compose.yml
version: '3'
services:
web:
image: nginx:1.20.1
container_name: web
restart: always
ports:
- "80:80"
volumes:
- ./nginx.d.conf:/etc/nginx/conf.d/nginx.conf
- ./nginx.conf:/etc/nginx/nginx.conf
- ./www/my-app:/app
php:
build:
context: .
dockerfile: myphp.dockerFile
container_name: php
restart: always
depends_on:
- web
volumes:
- ./www/my-app:/app
mysql:
image: mariadb:10.3.28
container_name: mysql
restart: always
depends_on:
- php
environment:
MYSQL_ROOT_PASSWORD: '******'
MYSQL_USER: 'root'
MYSQL_PASSWORD: '******'
MYSQL_DATABASE: 'my-database'
command: ["--default-authentication-plugin=mysql_native_password"]
volumes:
- mysqldata:/var/lib/mysql
- ./my.cnf:/etc/mysql/my.cnf
ports:
- 3306:3306
cache:
image: redis:5.0.3
container_name: cache
restart: always
ports:
- 6379:6379
networks:
- my-network
volumes:
- ./cache:/cache
volumes:
mysqldata: {}
networks:
my-network:
driver: "bridge"
So my symfony code is in the /www/my-app window's folder. This includes the /www/my-app/vendor too.
My application is running extremely slow (50-70 seconds). If i'm correct it's because the vendor folder is huge (80MB) and docker creates an image of it every time. Other discussions mentioned that vendor folder sould be moved into a new volume, and here i'm stuck with it. How to move and mount that in this case, and how should the docker-compose.yml look like after it?
I have a docker-compose file which contains a bunch of services. To that docker-compose file, I want to add another service now. The other service files (including its .env) are stored in another folder. I tried to build it like I show you below, but it isnt working. Where do I go wrong?
The docker-compose.yml is contained in the directory nft-trading-service, the other dockerfile which I am trying to include in this docker-compose.yaml is in its own folder nft-asset-updater.
So the structure looks like this
root/nft-trading-server (holding docker-compose.yml)
root/nft-asset-updater (holding its own Dockerfile and .env)
version: "3"
services:
nftapi:
env_file:
- .env
build:
context: .
ports:
- '5000:5000'
depends_on:
- postgres
networks:
- postgres
extra_hosts:
- "host.docker.internal:host-gateway"
restart: always
asset_update_service:
env_file:
- .env
build:
context: ../nft-asset-updater
dockerfile: .
ports:
- '9000:9000'
depends_on:
- postgres
networks:
- postgres
extra_hosts:
- "host.docker.internal:host-gateway"
restart: always
postgres:
container_name: postgres
image: postgres:latest
ports:
- "5432:5432"
volumes:
- /data/postgres:/var/lib/postgresql/data
env_file:
- docker.env
networks:
- postgres
pgadmin:
links:
- postgres:postgres
container_name: pgadmin
image: dpage/pgadmin4
ports:
- "8080:80"
env_file:
- docker.env
networks:
- postgres
networks:
postgres:
driver: bridge
ERROR: The Compose file '.\docker-compose.yml' is invalid because: Unsupported config option for services.db: 'pessoa'
My docker-compose
version: '3.7'
services:
db:
image: felipe/postgresql-pessoa
build:
context: .
dockerfile: Dockerfile
environment:
TZ: Americana/Sao_Paulo
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 123
POSTGRES_DBNAME: postgres
ports:
- "5435:5435"
networks:
- pessoa-network
pessoa:
image: felipe/pessoa-udemy
restart: always
build: ./Pessoa
work_dir: /Pessoa
environment:
TZ: Americana/Sao_Paulo
SPING_BOOT_ENVIRONMENT: Production
volumes:
- ./Pessoa: /Pessoa
- ~/ .m2:/root/ .m2
ports:
- "8082:8082"
command: mvn clean spring-boot:run
links:
- db
depends_on:
- db
networks:
- pessoa-network
networks:
pessoa-network:
driver: bridge
Better to test docker-compose online validator as there is indentation issue in the compose file.
Also, there is no config option work_dir it should be working_dir
Here is the fix docker-compose file.
version: '3.7'
services:
db:
image: felipe/postgresql-pessoa
build:
context: .
dockerfile: Dockerfile
environment:
TZ: Americana/Sao_Paulo
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 123
POSTGRES_DBNAME: postgres
ports:
- "5435:5435"
networks:
- pessoa-network
pessoa:
image: felipe/pessoa-udemy
restart: always
build: ./Pessoa
working_dir: /Pessoa
environment:
TZ: Americana/Sao_Paulo
SPING_BOOT_ENVIRONMENT: Production
volumes:
- "./Pessoa:/Pessoa"
ports:
- "8082:8082"
command: mvn clean spring-boot:run
links:
- db
depends_on:
- db
networks:
- pessoa-network
networks:
pessoa-network:
driver: bridge
Hello guys im setting up my first Docker env im strugleling with the setup for phpmyadmin i would like to use the native phpmyadmin from docker hub and link it to my apache see the code bellow does anybody have few suggestions? how can i handle this issue.
version: '2'
services:
# PHP Docker container
app:
build:
context: .
dockerfile: Dockerfile
links:
- mysql
ports:
- "8000:80"
volumes:
- ./app/:/app/
- ./:/docker/
volumes_from:
- storage
#######################################
# MySQL server
#######################################
mysql:
build:
context: docker/mysql/
dockerfile: MySQL-5.7.Dockerfile
restart: always
volumes_from:
- storage
env_file:
- etc/environment.yml
#######################################
# PHP MY ADMIN
#######################################
phpmyadmin:
image:
links:
ports:
- "8000:80"
environment:
MYSQL_USER: dev
MYSQL_ROOT_PASSWORD: root
storage:
build:
context: docker/storage/
volumes:
- /storage
MySQL Server Setup
MYSQL_ROOT_PASSWORD=dev
MYSQL_USER=dev
MYSQL_PASSWORD=dev
MYSQL_DATABASE=typo3
For Docker-compose file you can have something like
phpmyadmin:
image: phpmyadmin
restart: always
links:
- mysql
ports:
- 8000:80
environment:
- PMA_ARBITRARY=1
networks:
- Your-network
networks:
Your-network:
driver: bridge
You have to add your network to all your services ( mysql, php , .. )
then you can access your phpmyadmin by go to localhost:8000
Kindly find here complete version of docker compose file
version: '2'
services:
# PHP Docker container
app:
build:
context: .
dockerfile: Dockerfile
links:
- mysql
ports:
- "8000:80"
volumes:
- ./app/:/app/
- ./:/docker/
volumes_from:
- storage
networks:
- php-network
#######################################
# MySQL server
#######################################
mysql:
build:
context: docker/mysql/
dockerfile: MySQL-5.7.Dockerfile
restart: always
volumes_from:
- storage
env_file:
- etc/environment.yml
networks:
- php-network
#######################################
# PHP MY ADMIN
#######################################
phpmyadmin:
build:
context: .
dockerfile: PHPMYADMIN.Dockerfile
restart: always
links:
- mysql
ports:
- 8000:80
environment:
- PMA_ARBITRARY=1
networks:
- php-network
networks:
php-network:
driver: bridge
and PHPMYADMIN.Dockerfile will have only 1 line
FROM phpmyadmin/phpmyadmin
and you can access phpmyadmin on 192.168.99.100:8000