I have a setup based on docker-letsencrypt-nginx-proxy-companion running a django container and a wordpress container on the same Docker Host. I have added to domains to each of the container, so the wordpress container is reachable with mydomain.com and www.mydomain.com and the django container with subdomain.mydomain.com. This is configured in the VIRTUAL_HOST env and its working perfectly so far. I get all certificates and I can connect to each of them.
The main Issue I have now is, that the wordpress container needs to curl the django container and vice versa. But if I go into the django or wordpress container and try to make a call to e.g. subdomain.mydomain.com I get the following error:
$ curl mydomain.com
Hostname was NOT found in DNS cache
and then he tries to connect to the IP and is ending up in a timeout. If I make a curl from local or a different server I get a 200 without any problems on each of those. I read sth about a DNS resolve issue but atm I couldn't find a solution. Do you have a clue what I could do in this case?
Thanks in advance!
My Containers:
Nginx Proxy Compose
version: "2"
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- "/var/www/certificates:/etc/nginx/certs:ro"
- "/etc/nginx/vhost.d"
- "/usr/share/nginx/html"
- "/var/run/docker.sock:/tmp/docker.sock:ro"
letsencrypt-nginx-proxy-companion:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: letsencrypt-nginx-proxy-companion
restart: always
volumes_from:
- nginx-proxy
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "/var/www/certificates:/etc/nginx/certs:rw"
networks:
default:
external:
name: proxy-network
Wordpress Compose
version: '2'
services:
mariadb:
build:
context: .
dockerfile: build/env/mysql/Dockerfile
env_file: .env
restart: "always"
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
volumes:
- prod-database:/var/lib/mysql
php:
build:
context: .
dockerfile: build/env/php-fpm/Dockerfile
env_file: .env
restart: "always"
volumes:
- ${SRC_APP_PERSISTENT}:/var/www/html
links:
- mariadb:mysql
web:
build:
context: .
dockerfile: build/env/nginx/Dockerfile
restart: "always"
links:
- php:fpm
volumes_from:
- php
environment:
- VIRTUAL_HOST=mydomain.com,www.mydomain.com
- VIRTUAL_PORT=443
- VIRTUAL_NETWORK=proxy-network
- LETSENCRYPT_HOST=mydomain.com,www.mydomain.com
- LETSENCRYPT_EMAIL=info#mydomain.com
ports:
- "80"
volumes:
prod-database:
driver: local
networks:
default:
external:
name: proxy-network
Django Compose
version: '2'
volumes:
postgres_data_dev: {}
postgres_backup_dev: {}
services:
postgres:
build: ./compose/postgres
volumes:
- postgres_data_dev:/var/lib/postgresql/data
- postgres_backup_dev:/backups
environment:
- POSTGRES_USER=dbuser
django:
build:
context: .
dockerfile: ./compose/django/Dockerfile-dev
env_file: .env
command: /start-dev.sh
depends_on:
- postgres
environment:
- POSTGRES_USER=dbuser
- USE_DOCKER=yes
- VIRTUAL_HOST=subdomain.mydomain.com
- VIRTUAL_PORT=443
- VIRTUAL_NETWORK=proxy-network
- LETSENCRYPT_HOST=subdomain.mydomain.com
- LETSENCRYPT_EMAIL=info#mydomain.com
volumes:
- .:/app
ports:
- "8000"
links:
- postgres
- mailhog
pycharm:
build:
context: .
dockerfile: ./compose/django/Dockerfile-dev
depends_on:
- postgres
environment:
- POSTGRES_USER=dbuser
volumes:
- .:/app
links:
- postgres
mailhog:
image: mailhog/mailhog
ports:
- "8025:8025"
networks:
default:
external:
name: proxy-network
Related
i'm creating a local wordpress site with docker & ngnix.
Everything works, but i have a problem with the images.
i try to upload on my admin WP and the result is this
when i try to view the image i have this result
my docker-compose.yml file below
version: '3'
services:
php:
build: ./docker/php
volumes:
- "$PWD/wp-content:/var/www/wp-content"
- "$PWD/wp-config.local.php:/var/www/wp-config.php"
depends_on:
- mariadb
mariadb:
build: ./docker/mariadb
restart: "on-failure"
environment:
#MYSQL_ROOT_PASSWORD: "pass"
MYSQL_DATABASE: "wordpress"
MYSQL_USER: "user"
MYSQL_PASSWORD: "pass"
MYSQL_ROOT_PASSWORD: "pass"
volumes:
- "$PWD/docker/mariadb/dump:/docker-entrypoint-initdb.d"
nginx:
build: ./docker/nginx
ports:
- "8000:80"
links:
- php
volumes:
- "$PWD/wp-content:/var/www/wp-content"
- "$PWD/wp-config.local.php:/var/www/wp-config.php"
phpmyadmin:
image: phpmyadmin:5.1.0
ports:
- "8800:80"
depends_on:
- mariadb
environment:
PMA_HOST: "mariadb"
PMA_USER: "pass"
PMA_PASSWORD: "pass"
I am new to docker-compose and I am trying to deploy a docker compose file to deploy the following containers:
-Wordpress
-MySQL
-A gateway: nginx in my case
I expect that all traffic to Wordpress to pass through the gateway, and no container other than the gateway to be accessible from the host. The gateway container will display ports 80 and 443. Can you help me set this up and config the ?
I did the followings:
version: '3'
services:
db:
image: mysql:8.0
container_name: db
restart: unless-stopped
env_file: .env
environment:
- MYSQL_DATABASE=wordpress
volumes:
- dbdata:/var/lib/mysql
networks:
- app-network
wordpress:
depends_on:
- db
image: wordpress:5.1.1-fpm-alpine
container_name: wordpress
restart: unless-stopped
env_file: .env
environment:
- WORDPRESS_DB_HOST=db:3306
- WORDPRESS_DB_USER=$MYSQL_USER
- WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD
- WORDPRESS_DB_NAME=wordpress
volumes:
- wordpress:/var/www/html
networks:
- app-network
webserver:
depends_on:
- wordpress
image: nginx:1.15.12-alpine
container_name: webserver
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- wordpress:/var/www/html
- ./nginx-conf:/etc/nginx/conf.d
networks:
- app-network
volumes:
wordpress:
dbdata:
networks:
app-network:
driver: bridge
I created a setup for a wordpress installation with docker-compose:
version: '3'
services:
db:
image: mysql:8.0
container_name: db
restart: unless-stopped
env_file: .env
volumes:
- dbdata-dev:/var/lib/mysql
command: '--default-authentication-plugin=mysql_native_password'
networks:
- rn-dev-network
wordpress:
depends_on:
- db
image: wordpress:5.5.3-fpm-alpine
container_name: wordpress
restart: unless-stopped
env_file: .env
environment:
- WORDPRESS_DB_HOST=db:3306
- WORDPRESS_DB_USER=$MYSQL_USER
- WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD
- WORDPRESS_DB_NAME=$MYSQL_DATABASE
volumes:
- ./wordpress/wp-content:/var/www/html/wp-content
- ./wordpress/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
- wordpress-dev:/var/www/html
networks:
- rn-dev-network
webserver:
depends_on:
- wordpress
image: nginx:1.15.12-alpine
container_name: webserver
restart: unless-stopped
ports:
- "80:80"
volumes:
- wordpress-dev:/var/www/html
- ./nginx-conf:/etc/nginx/conf.d
networks:
- rn-dev-network
volumes:
wordpress-dev:
dbdata-dev:
networks:
rn-dev-network:
driver: bridge
Via FTP, I moved a theme into the wp-content/themes folder. The theme shows up on wordpress when starting the container, but it does not show any preview picture and is missing all pictures/assets when loading it.
I don't see what is missing. When I ssh into the container and check the folder, the volume is correctly linked and the wordpress theme is showing up in the correct folder.
Preview Screen of Wordpress Theme Setup
You need to mount the image file to the nginx container, because static content is served via the nginx container.
The Php container only executes the php.
webserver:
depends_on:
- wordpress
image: nginx:1.15.12-alpine
container_name: webserver
restart: unless-stopped
ports:
- "80:80"
volumes:
- wordpress-dev:/var/www/html
- ./wordpress/wp-content:/var/www/html/wp-content
- ./nginx-conf:/etc/nginx/conf.d
networks:
- rn-dev-network
I have a Magento 2 running on docker container and I would like to add a wordpress on the same container using one specific domain for each (blog.site and magento.site). I tried using nginx-proxy but it's not working my websites are not accessible anymore.
Here's my docker-compose.yml
version: "3"
services:
nginx-proxy:
image: jwilder/nginx-proxy
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/tmp/docker.sock
app:
image: markoshust/magento-nginx:1.13-8
links:
- db
- phpfpm
volumes: &appvolumes
- ~/.composer:/var/www/.composer:delegated
- appdata:/var/www/html
- sockdata:/sock
environment:
- "VIRTUAL_HOST=magento.site"
wordpress:
image: wordpress:latest
volumes:
- appwpdata:/var/www/html
environment:
- "VIRTUAL_HOST=blog.site"
phpfpm:
image: markoshust/magento-php:7.2-fpm-2
links:
- db
volumes: *appvolumes
db:
image: percona:5.7
ports:
- "3307:3307"
env_file: env/db.env
volumes:
- dbdata:/var/lib/mysql
phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- db
ports:
- '8080:80'
volumes:
- ./env/config.ini:/usr/local/etc/php/php.ini
volumes:
appdata:
appwpdata:
dbdata:
networks:
default:
external:
name: nginx-proxy
Hi I am setting up one docker image available on -https://github.com/10up/wp-local-docker
I have changed all the ports mentioned both .yml files -
- docker-compose.yml
- admin-compose.yml
Than I have done setup as mentioned in documentation on page.
My issue is I have already installed Apache 2 on my local on port 80 and I have setup docker nginx image on port 8088. After setup when I run the localhost:8088 it shows error "Secure Connection Failed" does not show default nginx page.
only thing I changed in .yml file is port which I want to expose all the images.
Any idea where I am doing wrong or miss any thing ? Below is my .yml files-
-docker-compose.yml
version: '3'
services:
mysql:
image: mysql:5
volumes:
- "./data/db:/var/lib/mysql:delegated"
ports:
- "3336:3306"
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: password
mailcatcher:
image: schickling/mailcatcher
ports:
- "1025:1025"
- "1080:1080"
environment:
MAILCATCHER_PORT: 1025
memcached:
image: memcached:latest
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.5
environment:
ES_JAVA_OPTS: "-Xms750m -Xmx750m"
ports:
- "9200:9200"
volumes:
- "./config/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:cached"
- "./config/elasticsearch/plugins:/usr/share/elasticsearch/plugins:cached"
- "./data/elasticsearch:/usr/share/elasticsearch/data:delegated"
phpfpm:
image: 10up/phpfpm
depends_on:
- mysql
- memcached
- elasticsearch
volumes:
- "./wordpress:/var/www/html:cached"
- "./config/php-fpm/php.ini:/usr/local/etc/php/php.ini:cached"
- "./config/php-fpm/docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini:cached"
- "./config/php-fpm/wp-cli.local.yml:/var/www/html/wp-cli.local.yml:cached"
- "~/.ssh:/root/.ssh:cached"
extra_hosts:
- "docker-local.localhost:172.18.0.1"
nginx:
depends_on:
- phpfpm
ports:
- "8088:80"
- "4443:443"
image: nginx:latest
volumes:
- "./wordpress:/var/www/html:cached"
- "./config/nginx/default.conf:/etc/nginx/conf.d/default.conf:cached"
- "./config/certs:/etc/nginx/certs:cached"
- "./logs/nginx:/var/log/nginx:cached"
wpsnapshots:
image: 10up/wpsnapshots
depends_on:
- mysql
- phpfpm
volumes:
- "./config/wpsnapshots:/home/wpsnapshots/.wpsnapshots:cached"
- "./wordpress:/var/www/html:cached"
-admin-compose.yml
version: '3'
services:
phpmyadmin:
image: phpmyadmin/phpmyadmin
environment:
- PMA_HOST mysql
links:
- mysql:db
ports:
- 8892:80
depends_on:
- mysql
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: password
phpmemcacheadmin:
image: hitwe/phpmemcachedadmin
ports:
- "8893:80"
depends_on:
- memcached