Wordpress on docker this site cant be reached - wordpress

So I have setup wordpress on docker this is my yml file configuration:
version: '3.8'
services:
wordpress:
build:
context: .
depends_on:
mysql:
condition: service_healthy
environment:
- WORDPRESS_DEBUG=true
- WORDPRESS_DB_HOST=mysql
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=password
volumes:
- .:/var/www/html/wp-content/plugins/plugin
ports:
- "8082:80"
mysql:
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=password
ports:
- "3308:3306"
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
interval: 1s
timeout: 3s
retries: 30
And this is my Dockerfile:
FROM wordpress:latest
RUN curl -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
&& chmod +x /usr/local/bin/wp
ADD ./bin/ /
RUN chmod +x /*.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]
When I run docker-compose up and go to localhost:8082 I get this This site can’t be reachedlocalhost refused to connect.
Inside wordpress docker logs I see this:
/usr/local/bin/docker-entrypoint.sh: line 99: exec: php-fpm: not found
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message
[Mon Oct 17 09:22:49.514781 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.54 (Debian) PHP/7.4.32 configured -- resuming normal operations
[Mon Oct 17 09:22:49.514849 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
172.19.0.1 - - [17/Oct/2022:09:23:42 +0000] "-" 408 0 "-" "-"
Cant find a way to fix it. Would appreciate some help.

Related

Docker: Apache in Apple Silicon M1

I have a docker-compose.yml file:
version: '1'
services:
mariadb:
image: 'docker.io/bitnami/mariadb:10.3-debian-10'
ports:
- '3307:3306'
volumes:
- ./db:/bitnami/mariadb
environment:
- MARIADB_USER=bn_wordpress
- MARIADB_DATABASE=bitnami_wordpress
- ALLOW_EMPTY_PASSWORD=yes
wordpress:
image: 'docker.io/bitnami/wordpress:5-debian-10'
ports:
- '8081:8080'
- '8444:8443'
volumes:
- ./wp:/bitnami/wordpress
depends_on:
- mariadb
environment:
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- WORDPRESS_DATABASE_USER=bn_wordpress
- WORDPRESS_DATABASE_NAME=bitnami_wordpress
- ALLOW_EMPTY_PASSWORD=yes
In Mac (Intel) and Linux, I run docker-compose up and it works perfectly.
But in Macbook M1, I installed Docker for Apple Silicon chip and updated rosetta, it prompts this at the end:
wordpress_1 | wordpress 15:48:36.49 INFO ==> ** Starting Apache **
wordpress_1 | [Tue Jul 13 15:48:36.652803 2021] [core:emerg] [pid 1] (95)Operation not supported: AH00023: Couldn't create the mpm-accept mutex
wordpress_1 | (95)Operation not supported: could not create accept mutex
wordpress_1 | AH00015: Unable to open logs
How can I overcome the issue? Appreciate your help!
Running docker compose with platform: linux/amd64 (i.e. running under QEMU) didn't fix this problem for me. Instead (in addition), I had to add:
Mutex posixsem
... to httpd.conf.
A bit late but have you tried adding platform: linux/amd64? Under both mariadb and wordpress
Let me share a summary for quick solution.
Connect to the container as the root user
docker exec -it -u 0 <container_name> /bin/bash
update httpd.conf file
echo "Mutex posixsem" >> /opt/bitnami/apache2/conf/httpd.conf
restart the container
docker restart <container_name>

"jrcs/letsencrypt-nginx-proxy-companion" docker image: too many certificates already issued for exact set of domains

I'm using jwilder/nginx-proxy and jrcs/letsencrypt-nginx-proxy-companion images to create the ssl certificates automatically. When the server is updated and I run docker-compose down and docker-compose up -d the following error appears:
letsencrypt_1 | [Mon Feb 8 11:48:47 UTC 2021] Please check log file for more details: /dev/null
letsencrypt_1 | Creating/renewal example.com certificates... (example.com www.example.com)
letsencrypt_1 | [Mon Feb 8 11:48:48 UTC 2021] Using CA: https://acme-v02.api.letsencrypt.org/directory
letsencrypt_1 | [Mon Feb 8 11:48:48 UTC 2021] Creating domain key
letsencrypt_1 | [Mon Feb 8 11:48:48 UTC 2021] The domain key is here: /etc/acme.sh/email#gmail.com/example.com/example.com.key
letsencrypt_1 | [Mon Feb 8 11:48:48 UTC 2021] Multi domain='DNS:example.com,DNS:www.example.com'
letsencrypt_1 | [Mon Feb 8 11:48:48 UTC 2021] Getting domain auth token for each domain
letsencrypt_1 | [Mon Feb 8 11:48:49 UTC 2021] Create new order error. Le_OrderFinalize not found. {
letsencrypt_1 | "type": "urn:ietf:params:acme:error:rateLimited",
letsencrypt_1 | "detail": "Error creating new order :: too many certificates already issued for exact set of domains: example.com,www.example.com: see https://letsencrypt.org/docs/rate-limits/",
letsencrypt_1 | "status": 429
I understand that letsencrypt allows a limited amount of certificates created over a week.
Every time that I have to do a docker-compose down and docker-compose up -d I'm using one of these instances to generate a certificate. Now I have reached the limit and can't use the service.
How to avoid certificates generating if is not necessary?
Is there a way to reset the counter for this week to keep using the site?
My docker-compose.yml
version: "3"
services:
db:
image: postgres:12
restart: unless-stopped
env_file: ./.env
volumes:
- postgres_data:/var/lib/postgresql/data
web:
build:
context: .
restart: unless-stopped
env_file: ./.env
command: python manage.py runserver 0.0.0.0:80
volumes:
- static:/code/static/
- .:/code
#ports:
# - "8000:8000"
depends_on:
- db
nginx-proxy:
image: jwilder/nginx-proxy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- certs:/etc/nginx/certs:ro
- vhostd:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
labels:
- com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
restart: always
environment:
- NGINX_PROXY_CONTAINER=nginx-proxy
volumes:
- certs:/etc/nginx/certs:rw
- vhostd:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/var/run/docker.sock:ro
nginx:
image: nginx:1.19
restart: always
expose:
- "80"
volumes:
- ./config/nginx/conf.d:/etc/nginx/conf.d
- static:/code/static
- ./../ecoplatonica:/usr/share/nginx/html:ro
env_file: ./.env
depends_on:
- web
- nginx-proxy
- letsencrypt
volumes:
.:
postgres_data:
static:
certs:
html:
vhostd:
I had this problem and finally got it figured out.
You need to add a volume to the nginx-proxy: and letsencrypt: services' volumes: sections - something like this:
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- certs:/etc/nginx/certs:ro
- vhostd:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- acme:/etc/acme.sh
and then at the end of the docker-compose.yml file, I added:
volumes:
.:
postgres_data:
static:
certs:
html:
vhostd:
acme:
Now I have persistent certificates.
You need to mount acme:/etc/acme.sh folder for nginx-proxy because it's created each time when you do up/down. Plus, add acme: to the last volumes: section.
Entry from your log file proves it:
letsencrypt_1 | [Mon Feb 8 11:48:48 UTC 2021] The domain key is here: /etc/acme.sh/email#gmail.com/example.com/example.com.key
Also, take a look at this doc

Docker local environment custom local domains (hosts file?)

I'm a bit new to docker, but am searching this for quite a long time now.
I am using docker almost always with this container: https://hub.docker.com/_/wordpress/ , because most of my project are WordPress based.
The point is that every time I'm running this container, I'm running it on a localhost domain. Now at the company I'm working, we still using Virtual Machine. Here I have a 'homestead.yml' file, were I can add a custom domain and it's path. I also need to add this to my hosts file, and run a vagrant provision.
I don't want to use Virtual Machine on this Mac, because I like the speed of using Docker, but I do want the custom domains. For example; I work on a project called 'sunglasses', I want to create a local domain called 'sunglasses.local' for my local environment. But i can't seem to get it working...
My docker-compose file looks like this:
version: '3.1'
services:
wordpress:
depends_on:
- db
image: wordpress:latest
restart: unless-stopped
working_dir: /var/www/html
volumes:
- ./wp-content:/var/www/html/wp-content
# - /Users/username/dev/wordpress-foundation-boilerplate/wp-content:/var/www/html/wp-content
# - /Users/username/dev/docker-wp-demo/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
environment:
WORDPRESS_DB_NAME: database
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_PASSWORD: p4ssw0rd!
WORDPRESS_TABLE_PREFIX: wp_
WORDPRESS_DEBUG: 1
WORDPRESS_CONFIG_EXTRA: | # Add config to wp-config.php
define('FS_METHOD', 'direct');
define('WP_DEBUG_LOG', true);
define( 'WP_DEBUG', true );
ports:
- 8000:80
- 443:443
networks:
- back
db:
image: mysql:5.7
restart: unless-stopped
volumes:
- db_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: p4ssw0rd!
networks:
- back
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- 8080:80
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: p4ssw0rd!
networks:
- back
networks:
back:
volumes:
db_data:
I'm using Gasmask (see: http://clockwise.ee/) for editing my hosts file, and already added the domain I want to use with the right IP-adres.
Any idea what I'm missing? I don't now were to place the domain address in my docker-compose file. I have tried added it under 'ports' but this didn't even run my docker-compose file. I hope someone knows what I'm doing wrong.
At work we use dnsmasq to pass requests to TLDs that end in .docker to localhost. Here is how:
Requirements: homebrew and administration access
To forward .docker TLDs, install & configure Dnsmasq.
$ brew up && brew install dnsmasq
$ sudo mkdir -p /etc/resolver
$ echo 'nameserver 127.0.0.1' | sudo tee -a /etc/resolver/docker > /dev/null
$ echo 'address=/docker/127.0.0.1' | tee -a /usr/local/etc/dnsmasq.d/docker-tld.conf > /dev/null
$ sudo brew services start dnsmasq
Note: The resolver will start working after a reboot
Modify /usr/local/etc/dnsmasq.conf
...
listen-address=127.0.0.1
...
conf-dir=/usr/local/etc/dnsmasq.d/,*.conf
Test the DNS server
$ dig test.docker #127.0.0.1
; <<>> DiG 9.9.7-P3 <<>> test.docker #127.0.0.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40401
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;test.docker. IN A
;; ANSWER SECTION:
test.docker. 0 IN A 127.0.0.1
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Thu Feb 08 16:24:12 CET 2018
;; MSG SIZE rcvd: 45
Test the configuration
; Make sure your DNS is still working.
$ ping -c 1 www.google.com
PING www.google.com (216.58.206.4): 56 data bytes
64 bytes from 216.58.206.4: icmp_seq=0 ttl=53 time=26.789 ms
--- www.google.com ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 26.789/26.789/26.789/0.000 ms
Check that .docker TLDs are working
$ ping -c 1 test.docker
PING test.docker (127.0.0.1): 56 data bytes
Source: Passing Curiosity

Docker exec fails, permission denied: unknown

I'm new to docker and I'm just trying to create a simple Symfony API. I ran docker-compose up -d which created these containers:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
071de3320346 willdurand/elk "/usr/bin/supervisor…" About a minute ago Up About a minute 0.0.0.0:81->80/tcp simple-api_elk_1
c24132f645be simple-api_nginx "nginx" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 443/tcp simple-api_nginx_1
37128a03b667 simple-api_php "php-fpm7 -F" About a minute ago Up About a minute 0.0.0.0:9000->9000/tcp simple-api_php_1
aa7738c59891 mysql "docker-entrypoint.s…" About a minute ago Up About a minute 3306/tcp, 33060/tcp, 0.0.0.0:3307->3307/tcp simple-api_db_1
I then took the id from the simple-api_php and ran
docker exec 37128a03b667 composer create-project symfony/website-skeleton symfony-api
It returns:
OCI runtime exec failed: open /tmp/runc-process126262263: permission denied: unknown
here is my docker-compose.travis.yml:
version: '2'
services:
db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: symfony
MYSQL_USER: symfony
MYSQL_PASSWORD: symfony
php:
build: ./php-fpm
expose:
- "9000"
volumes:
- ./symfony:/var/www/symfony
- ./logs/symfony:/var/www/symfony/var/logs
links:
- db
nginx:
build: ./nginx
ports:
- "80:80"
links:
- php
volumes_from:
- php
volumes:
- ./logs/nginx/:/var/log/nginx
elk:
image: willdurand/elk
ports:
- "81:80"
volumes:
- ./elk/logstash:/etc/logstash
- ./elk/logstash/patterns:/opt/logstash/patterns
volumes_from:
- php
- nginx
Just don't have enough knowledge to troubleshoot this.
Thanks!!
You should edit your elk service.
elk:
image: willdurand/elk
ports:
- "81:80"
volumes:
- ./elk/logstash:/etc/logstash
- ./elk/logstash/patterns:/opt/logstash/patterns <-------- remove this line
volumes_from:
- php
- nginx <-------- remove this line
Note: comments are marked with arrow <------
Also, if you still have the same issue - try to remove images and containers and then rebuild them.
// This command will remove all containers and images in your docker-compose.travis.yml file
$: docker-compose down
// Or you can remove container and images manually
$: docker rm container_name
$: docker rmi image_name

Docker - pdo_mysql (nginx + PHP7 + MariaDB + phpMyAdmin) Symfony + Doctrine

I have a little bit problem with install pdo_mysql into my docker container.
In Symfony I got this error:
PDOException PDOException DriverException
HTTP 500 Internal Server Error
An exception occurred in driver: could not find driver
Symfony - config.yml
doctrine:
dbal:
driver: pdo_mysql
Dockerfile
FROM phpdockerio/php7-fpm:latest
# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install vim mc apt-utils \
&& php7-pdo_mysql php7-pdo \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
/usr/share/doc/*
WORKDIR "/var/www/project"
docker-compose.yml
version: "3.1"
services:
mysql:
image: mariadb
container_name: project-mariadb
environment:
MYSQL_ROOT_PASSWORD: root
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: project-pma
restart: always
links:
- mysql
ports:
- 8183:80
environment:
PMA_HOST: mysql
PMA_USER: root
PMA_PASSWORD: root
webserver:
image: nginx:alpine
container_name: project-websrv
working_dir: /var/www/project
volumes:
- ../../Sources/project/trunk/src/:/var/www/project
- ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- "8080:80"
links:
- php-fpm
php-fpm:
build: phpdocker/php-fpm
container_name: project-php
working_dir: /var/www/project
volumes:
- ../../Sources/project/trunk/src/:/var/www/project
- ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.0/fpm/conf.d/99-
overrides.ini
links:
- mysql
docker-compose ps
d:\Work\DockerContainers\project>docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------
project -mariadb docker-entrypoint.sh mysqld Up 3306/tcp
project -php /bin/sh -c /usr/bin/php-fpm Up 9000/tcp
project -pma /run.sh phpmyadmin Up 0.0.0.0:8183->80/tcp
project -websrv nginx -g daemon off; Up 0.0.0.0:8080->80/tcp
d:\Work\DockerContainers\project>
I have this linux version:
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
I tried to change the package names for pdo_mysql in Dockerfile what I found on the forums, I tried installing through apt-get install directly in the container, but nothing helped I always get the same message:
/bin/sh: 1: docker-php-ext-install: not found (docker-compose build)
E: Unable to locate package php7-mysql (pdo_mysql etc.) (root in docker container)
php-ini-overrides.ini
upload_max_filesize = 100M
post_max_size = 108M
extension=pdo.so
extension=pdo_mysql.so
I don´t know if is this problem in Symfony configuration or problem with docker
Can you help me, please?
Thanks a lot

Resources