'dsn' => 'mysql:host=mariadb;port=3361;dbname=demo_site;',
Так не заработает, ведь этот порт из контейнера недоступен, ввиду того, что он находится в хостовой системе, то есть за рамками контейнера и виртуальной сети, которая объединяет контейнеры. ports:
- "192.168.0.22:22:22"
version: '3.1'
services:
db:
image: postgres:13.4
container_name: postgres13
restart: always
environment:
POSTGRES_PASSWORD: strong_password
volumes:
- ./data:/var/lib/postgresql/data
ports:
- '5432:5432'
~$ mkdir ./public
~$ ls -1 ./public
~$
~$ cat docker-compose.yml
version: "2.3"
services:
wp_site:
image: "wordpress:php8.0-fpm"
container_name: "wordpress"
volumes:
- "./public:/var/www/html:delegated"
~$ docker-compose up -d
~$ ls -1 public/
index.php
license.txt
readme.html
...
if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# if the directory exists and WordPress doesn't appear to be installed AND the permissions of it are root:root, let's chown it (likely a Docker-created directory)
if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi
echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
fi
sourceTarArgs=(
--create
--file -
--directory /usr/src/wordpress
--owner "$user" --group "$group"
)
targetTarArgs=(
--extract
--file -
)
if [ "$uid" != '0' ]; then
# avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted"
targetTarArgs+=( --no-overwrite-dir )
fi
# loop over "pluggable" content in the source, and if it already exists in the destination, skip it
# https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded)
for contentPath in \
/usr/src/wordpress/.htaccess \
/usr/src/wordpress/wp-content/*/*/ \
; do
contentPath="${contentPath%/}"
[ -e "$contentPath" ] || continue
contentPath="${contentPath#/usr/src/wordpress/}" # "wp-content/plugins/akismet", etc.
if [ -e "$PWD/$contentPath" ]; then
echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)"
sourceTarArgs+=( --exclude "./$contentPath" )
fi
done
tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}"
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
fi
docker inspect --format='{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' <container_name>
-p
или директива ports:
в compose), тогда сможешь подключиться к контейнеру с хостовой машины.