--allow-root не работает при запуске wp-cli в контейнере Docker - PullRequest
0 голосов
/ 25 октября 2019

При использовании WP CLI в Docker мне нужно выполнить его как root. Мне нужно добавить флаг --allow-root непосредственно в .bashrc, и я пытаюсь выяснить, почему он не работает.

FROM webdevops/php-dev:7.3

# configure postfix to use mailhog
RUN postconf -e "relayhost = mail:1025"

# install wp cli
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
    chmod +x wp-cli.phar && \
    mv wp-cli.phar /usr/local/bin/wp && \
    echo 'wp() {' >> ~/.bashrc && \
    echo '/usr/local/bin/wp "$@" --allow-root' >> ~/.bashrc && \
    echo '}' >> ~/.bashrc

WORKDIR /var/www/html/

мой .bashrc

# ~/.bashrc: executed by bash(1) for non-login shells.

# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
# umask 022

# You may uncomment the following lines if you want `ls' to be colorized:
# export LS_OPTIONS='--color=auto'
# eval "`dircolors`"
# alias ls='ls $LS_OPTIONS'
# alias ll='ls $LS_OPTIONS -l'
# alias l='ls $LS_OPTIONS -lA'
#
# Some more alias to avoid making mistakes:
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'
wp() {
/usr/local/bin/wp "$@" --allow-root
}

, когда япопробуйте выполнить любую команду wp, я получаю эту ошибку:

Error: YIKES! It looks like you're running this as root. You probably meant to run this as the user that your WordPress installation exists under.

If you REALLY mean to run this as root, we won't stop you, but just bear in mind that any code on this site will then have full control of your server, making it quite DANGEROUS.

If you'd like to continue as root, please run this again, adding this flag:  --allow-root

If you'd like to run it as the user that this site is under, you can run the following to become the respective user:

    sudo -u USER -i -- wp <command>

Похоже, что командная строка не учитывает то, что я ввожу в .bashrc

Ребята, у вас есть какие-либо предложения, какрешить эту проблему?

...