~$ 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), тогда сможешь подключиться к контейнеру с хостовой машины. FROM ubuntu:latest
RUN apt update && apt install -y openssl
RUN mkdir -p /etc/cert
RUN /bin/bash -c "openssl req -x509 \
-newkey rsa:2048 -nodes -sha256 \
-out /etc/cert/localhost.crt \
-keyout /etc/cert/localhost.key \
-subj '/CN=localhost' \
-extensions EXT \
-config <( \
printf '[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth')"
docker build .
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM ubuntu:latest
---> 1318b700e415
Step 2/4 : RUN apt update && apt install -y openssl
---> Using cache
---> e608bba6cb59
Step 3/4 : RUN mkdir -p /etc/cert
---> Using cache
---> b89d4c7495a3
Step 4/4 : RUN /bin/bash -c "openssl req -x509 -newkey rsa:2048 -nodes -sha256 -out /etc/cert/localhost.crt -keyout /etc/cert/localhost.key -subj '/CN=localhost' -extensions EXT -config <( printf '[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth')"
---> Running in a4012f6c4893
Generating a RSA private key
................................................+++++
..+++++
writing new private key to '/etc/cert/localhost.key'
-----
Removing intermediate container a4012f6c4893
---> 6ea49c8d9ada
Successfully built 6ea49c8d9ada