Dockerfile传递错误的mysql主机IP地址

我在本地机器上创build了一个构build,并且工作得很好。 现在试图在服务器中做同样的事情。它不是通过在Dockerfile中设置的host-ip,而是通过172.17.0.3并抛出以下错误

这是错误:

Step 22/25 : RUN cd /usr/html/bin && ./magento setup:config:set --db-host=172.17.0.2 --db-name=mydb --db-user=tara --db-password=password ---> Running in 7bbe53f5d054 SQLSTATE[HY000] [1045] Access denied for user 'tara'@'172.17.0.3' (using password: YES) [InvalidArgumentException] Parameter validation failed 

*主机IP来自另一个正在运行的容器的IP地址。 这是172.17.0.2 *

为什么在连接过程中会出现错误的IP地址?

这里是dockerfile:

 FROM docker-php:0.2 #mysqql setup ENV DB_HOST 172.17.0.2 ENV DB_NAME mydb ENV DB_USER admin ENV DB_PASSWORD password #magenot admin user ENV ADMIN_USER tara ENV ADMIN_PASSWORD password123 ENV ADMIN_FIRSTNAME tara ENV ADMIN_LASTNAME gurung ENV ADMIN_EMAIL tara.email@somelink.net ADD ./magento2 /usr/html/ WORKDIR /usr/html/ RUN find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \; RUN find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \; RUN chown -R :docker . RUN chmod u+x bin/magento RUN composer install CMD echo "Success installed Magento" ENTRYPOINT ["/home/docker/run.sh"] #get into the magento isntallation dir #get into the magento isntallation dir #start setting the necessasry file permission first RUN cd /usr/html && \ chmod 777 generated -R && \ chmod 777 var -R RUN cd /usr && \ chown -R docker:docker html #start running the magento commands to install RUN cd /usr/html/bin && \ ./magento setup:config:set --db-host=$DB_HOST --db-name=mydb --db-user=bhavi --db-password=password #installing the magento with admin user created RUN cd /usr/html/bin && \ ./magento setup:install --admin-user=$ADMIN_USER --admin-password=$ADMIN_PASSWORD --admin-firstname=$ADMIN_FIRSTNAME --admin-lastname=$ADMIN_LASTNAME --admin-email=ADMIN_EMAIL --use-rewrites=1 RUN chmod 777 vendor -R RUN cd /usr && \ chown -R docker:docker html