Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 云sql代理无法从docker容器工作_Google Cloud Platform_Google Compute Engine_Load Balancing_Google Cloud Sql_Google Cloud Proxy - Fatal编程技术网

Google cloud platform 云sql代理无法从docker容器工作

Google cloud platform 云sql代理无法从docker容器工作,google-cloud-platform,google-compute-engine,load-balancing,google-cloud-sql,google-cloud-proxy,Google Cloud Platform,Google Compute Engine,Load Balancing,Google Cloud Sql,Google Cloud Proxy,我的应用程序运行在docker容器上,部署时启用了google计算组和自动调用。 iam面临的问题是从自动缩放的计算实例连接mysql实例,但它无法正常工作 Dockerfile FROM ubuntu:16.04 RUN apt-get update && apt-get install -y software-properties-common && \ ...installation other extenstion RUN curl -sS https:/

我的应用程序运行在docker容器上,部署时启用了google计算组和自动调用。 iam面临的问题是从自动缩放的计算实例连接mysql实例,但它无法正常工作

Dockerfile

FROM ubuntu:16.04
RUN apt-get update && apt-get install -y software-properties-common && \
...installation other extenstion
RUN curl -sS https://getcomposer.org/installer | \
    php -- --install-dir=/usr/bin/ --filename=composer
COPY . /var/www/html
CMD cd /var/www/html
RUN composer install
ADD nginx.conf/default /etc/nginx/sites-available/default
RUN wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy
RUN chmod +x cloud_sql_proxy
RUN mkdir /cloudsql
RUN chmod 777 /cloudsql
RUN chmod 777 -R storage bootstrap/cache
EXPOSE 80
**CMD service php7.1-fpm start && nginx -g "daemon off;" &&  ./cloud_sql_proxy -dir=/cloudsql -instances=<connectionname>=tcp:0.0.0.0:3306 -credential_file=file.json &**
来自ubuntu:16.04的

运行apt-get-update&&apt-get-install-y软件属性common&&\
…安装其他扩展
运行curl-sShttps://getcomposer.org/installer | \
php--install dir=/usr/bin/--filename=composer
抄袭/var/www/html
CMD cd/var/www/html
运行composer安装
添加nginx.conf/default/etc/nginx/sites available/default
运行wgethttps://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O云计算\u sql\u代理
运行chmod+x cloud\u sql\u代理
运行mkdir/cloudsql
运行chmod777/cloudsql
运行chmod 777-R存储引导/缓存
暴露80
**CMD服务php7.1-fpm start&&nginx-g“守护进程关闭”&&&./cloud\u sql\u proxy-dir=/cloudsql-instances==tcp:0.0.0:3306-credential\u file=file.json&**
最后一行
/cloud\u sql\u proxy-dir=/cloudsql-instances==tcp:0.0.0:3306-credential\u file=file.json&
在我运行容器时未执行

如果我在容器内运行这个
/cloud\u sql\u proxy-dir=/cloudsql-instances==tcp:0.0.0:3306-credential\u file=file.json&
(通过docker命令转到容器),它正在工作,当我再次关闭终端时,它停止工作

甚至我也试着在后台跑步,但没有运气

有人知道吗?

已经被

  • 创建start.sh文件并将所有命令移动到start.sh
  • 在启动sql代理之后,我放置sleep 10并启动nginx和php
  • 现在它的工作如预期

    Dockerfile
    FROM ubuntu:16.04
    ...other command
    ADD start.sh /
    RUN chmod +x /start.sh
    EXPOSE 80
    CMD ["/start.sh"]
    
    这是start.sh文件

    //start.sh
    #!/bin/sh
    ./cloud_sql_proxy -dir=/cloudsql -instances=<connectionname>=tcp:0.0.0.0:3306     -credential_file=<file>.json &
    sleep 10
    service php7.1-fpm start
    nginx -g "daemon off;"
    
    //start.sh
    #!/垃圾箱/垃圾箱
    ./cloud\u sql\u proxy-dir=/cloudsql-instances==tcp:0.0.0:3306-credential\u file=.json&
    睡眠10
    服务php7.1-fpm启动
    nginx-g“守护进程关闭”
    
    您是否尝试更改最新的命令顺序并从sql代理命令开始?能否显示Docker生成的错误日志?现在它开始工作了我把sleep 10放在shell脚本上太棒了!,如果您在响应中添加文件并将其标记为已接受,那将是非常棒的!