Error response from daemon: cannot mount volume over existing file, file exists/merged/usr/local/etc/php/conf.d/local.ini - docker-volume

Hi am trying to run the image which is pulled from the docker hub.Below is my docker-compose file code.Error is regarding the Volume mount if i tried to change any modifications unable to run project.
version: '3'
services:
#PHP Service
app:
build:
context: .
dockerfile: ./deployment/dev/Dockerfile
image: digitalocean.com/php
container_name: ${APP_NAME}_app
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: ${APP_NAME}_app
SERVICE_TAGS: dev
working_dir: /var/www
networks:
- app-network
#Nginx Service
webserver:
image: nginx:alpine
container_name: ${APP_NAME}_webserver
restart: unless-stopped
tty: true
ports:
- "8080:80"
networks:
- app-network

Related

How can I fix this issue with Yaml file?

Hi I am trying to run docker-compose build --no-cache but I keep getting errors.
yaml.parser.ParserError: while parsing a block mapping
in ".\docker-compose.yml", line 1, column 1
expected <block end>, but found '<block mapping start>'
in ".\docker-compose.yml", line 2, column 5
docker-compose.yml:
Please help me to to format this I looked online but I couldn't find any linter that could do this I keep getting errors.
Thanks.
This is my docker composer file:
s is my docker file docker-compose.yml
version: '3'
services:
#PHP-FPM service
app:
build:
context: .
dockerfile: Dockerfile
container_name: store
restart: unless-stopped
tty: true
working_dir: /var/www
volumes:
- ./:/var/www
- ./docker-files/php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
-app-network
#Nginix service
webserver:
image: nginx-alpine
container_name: store-webserver
restart: unless-stopped
tty: true
ports:
- "8100:80"
- "8143:443"
volumes:
- ./:/var/www
- ./docker-files/nginx/conf.d:/etc/nginx/conf.d/
networks:
-app-network
#MariaDB service
db:
image: mariadb:10.5.6
container_name: store-mariadb
restart: unless-stopped
tty: true
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: store
MYSQL_USER: store
MYSQL_PASSWORD: root
volumes:
- mariadbData:/var/lib/mysql
- ./docker-files/mariadb/my.cnf:/etc/mysql/my.cnf
networks:
-app-network
#Volumes
volumes:
mariadbData:
driver: local
#Networks
networks:
app-network:
driver: bridge
I have noticed some spacing issues on your YAML file, one of them is that the version and services sections are not on the same level, you have to know that docker-compose files and YAML have a strict syntax and a spacing might ruin everything for you here is a fix to your compose file, make sure to learn and read more about docker-compose documentation.
Not sure what's the behavior of your environment but here is a correct YAML syntax for your example:
version: '3'
services:
#PHP-FPM service
app:
build:
context: .
dockerfile: Dockerfile
container_name: store
restart: unless-stopped
tty: true
working_dir: /var/www
volumes:
- ./:/var/www
- ./docker-files/php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
#Nginix service
webserver:
image: nginx-alpine
container_name: store-webserver
restart: unless-stopped
tty: true
ports:
- "8100:80"
- "8143:443"
volumes:
- ./:/var/www
- ./docker-files/nginx/conf.d:/etc/nginx/conf.d/
networks:
- app-network
#MariaDB service
db:
image: mariadb:10.5.6
container_name: store-mariadb
restart: unless-stopped
tty: true
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: store
MYSQL_USER: store
MYSQL_PASSWORD: root
volumes:
- mariadbData:/var/lib/mysql
- ./docker-files/mariadb/my.cnf:/etc/mysql/my.cnf
networks:
- app-network
#Volumes
volumes:
mariadbData:
driver: local
#Networks
networks:
app-network:
driver: bridge

"Unable to find template" with Docker

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

How to use docker volume with docker image from dockerhub

Deploy my project using docker compose. At the moment, my project is being built locally, from local folders with projects. Docker uses Laravel service, VueJS service, NGINX service, Mysql service and Redis service.
I set up a docker compose from an article from digital ocean. The question is as follows. In the article, it was necessary to create volumes (volumes) that linked the files of my application locally with the files of the container, but what should I do if I want to build my project using DockerHub, after all, I will no longer have the files stored locally.
I tried without these volumes in the backend and webserver, but then without any errors during the assembly, I cannot reach the server via the localhost.
Do I just need to push the image right away with the volume? Here is my compose.yml:
version: '3'
services:
#VueJS Service
frontend:
build: ./frontend
container_name: frontend
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: frontend
working_dir: /var/www/frontend
ports:
- "3000:80"
volumes:
- ./frontend/:/var/www/frontend
- ./frontend/node_modules:/var/www/frontend/node_modules
networks:
- backend-network
#PHP Service
backend:
build: ./backend
container_name: backend
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: backend
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./backend/:/var/www
- ./backend/php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- backend-network
#Nginx Service
webserver:
image: nginx:alpine
container_name: webserver
restart: unless-stopped
tty: true
ports:
- "443:443"
- "8080:8080"
volumes:
- ./backend/:/var/www
- ./backend/nginx/conf.d/:/etc/nginx/conf.d/
networks:
- backend-network
#MySQL Service
db:
image: mysql:5.7.22
container_name: db
restart: unless-stopped
tty: true
ports:
- "33062:3306"
environment:
MYSQL_DATABASE: qcortex
MYSQL_ROOT_PASSWORD: kc3wcfjk5
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes:
- dbdata:/var/lib/mysql
- ./backend/mysql/my.cnf:/etc/mysql/my.cnf
networks:
- backend-network
#Redis
redis:
image: caster977/redis
restart: unless-stopped
container_name: redis
networks:
- backend-network
#Docker Networks
networks:
backend-network:
driver: bridge
#Volumes
volumes:
dbdata:
driver: local

Http request two container each other with one nginx

I can not use curl to communicate between curator and dispenser container.
I want to access from curator container like curl http://dispenser.shadysmaoui.test.
these two container, I can request by http request from host normally.
docker-compose.yml
version: '3'
services:
webserver:
image: nginx:alpine
restart: unless-stopped
tty: true
ports:
- "80:80"
- "443:443"
volumes:
- ./apps/curator/:/var/www/curator
- ./apps/dispenser/:/var/www/dispenser
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./docker/nginx/sites/:/etc/nginx/conf.d/
- ./docker/nginx/ssl/:/etc/ssl/
networks:
- app-network
curator:
build:
context: apps/curator
dockerfile: Dockerfile
image: digitalocean.com/php
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: curator
SERVICE_TAGS: dev
working_dir: /var/www/curator
volumes:
- ./apps/curator/:/var/www/curator
- ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
dispenser:
build:
context: apps/dispenser
dockerfile: Dockerfile
image: digitalocean.com/php
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: dispenser
SERVICE_TAGS: dev
working_dir: /var/www/dispenser
volumes:
- ./apps/dispenser/:/var/www/dispenser
- ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
networks:
app-network:
driver: bridge
volumes:
dbdata:
driver: local
Between containers use the service name : curl http://webserver or https://webserver

Container files not updated when changed from the host mapped volume

I have the following docker-compose.yml:
version: '3'
services:
web:
build:
context: .
dockerfile: ./.docker/node.dockerfile
volumes:
- D:\Proj\Web:/app
ports:
- '3000:3000'
depends_on:
- 'db'
networks:
- holder-network
restart: on-failure
tty: true
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
networks:
- holder-network
restart: always
environment:
MYSQL_ROOT_PASSWORD: P#ssw0rd
MYSQL_DATABASE: holder_db
MYSQL_USER: holder_usr
MYSQL_PASSWORD: P#ssw0rd
networks:
holder-network:
driver: bridge
volumes:
db_data:
And the node.dockerfile:
FROM node:7.10
MAINTAINER Juliano Nunes
RUN mkdir /var/www
RUN npm install nodemon -g
WORKDIR /var/www
ADD . /var/www
RUN npm install
CMD nodemon
I'm changing the files under D:\Proj\Web from the host, however it doesn't update the files in the container. Why?
I've found the error. My docker-compose.yml was using /app as the path and node.dockerfile was using /var/www.
Here's the updated (working) version:
version: '3'
services:
web:
build:
context: .
dockerfile: ./.docker/node.dockerfile
volumes:
- D:\Proj\Web:/var/www
ports:
- '3000:3000'
depends_on:
- 'db'
networks:
- holder-network
restart: on-failure
tty: true
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
networks:
- holder-network
restart: always
environment:
MYSQL_ROOT_PASSWORD: P#ssw0rd
MYSQL_DATABASE: holder_db
MYSQL_USER: holder_usr
MYSQL_PASSWORD: P#ssw0rd
networks:
holder-network:
driver: bridge
volumes:
db_data:
To map a host volume in a container running on docker for windows, you need to ensure your drive is shared into the embedded VM. Otherwise, the directory will mount from the VM's filesystem which will be empty at that location. You need to go into the docker settings on Windows and add the D drive to the shared directory list. See docker's documentation on this here: https://docs.docker.com/docker-for-windows/#shared-drives

Resources