首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将值传递给docker文件

如何将值传递给docker文件
EN

Stack Overflow用户
提问于 2018-03-09 10:58:11
回答 1查看 293关注 0票数 1

这里是我的码头文件

代码语言:javascript
复制
FROM ubuntu:16.04
   
   RUN apt-get update && apt-get install -y wget && \
       wget https://dev.mysql.com/get/Downloads/MySQL-Router/mysql-router_2.1.6-1ubuntu16.04_amd64.deb && \
       apt-get install -y ./mysql-router_2.1.6-1ubuntu16.04_amd64.deb && \
       apt-get update && \
       apt-get install mysql-router && \
       useradd -ms /bin/bash router
   USER router
   WORKDIR /home/router
   RUN mysqlrouter --bootstrap ic@192.168.1.136:3306 -d myrouter
   
   CMD ["myrouter/start.sh"]

这是Docker交互式输出:

代码语言:javascript
复制
Sending build context to Docker daemon  2.048kB
       Step 1/6 : FROM ubuntu:16.04
        ---> f975c5035748
       Step 2/6 : RUN apt-get update && apt-get install -y wget &&     wget https://dev.mysql.com/get/Downloads/MySQL-Router/mysql-router_2.1.6-1ubuntu16.04_amd64.deb &&     apt-get install -y ./mysql-router_2.1.6-1ubuntu16.04_amd64.deb &&     apt-get update &&     apt-get install mysql-router &&     useradd -ms /bin/bash router
        ---> Using cache
        ---> 1bf5a87eb556
       Step 3/6 : USER router
        ---> Using cache
        ---> ccedbc3db924
       Step 4/6 : WORKDIR /home/router
        ---> Using cache
        ---> ab67e9623a09
       Step 5/6 : RUN mysqlrouter --bootstrap ic@192.168.1.136:3306 -d myrouter
        ---> Running in 9494d8083fd0
       Please enter MySQL password for ic: 
   Error: Unable to connect to the metadata server: Error connecting to MySQL server at 192.168.1.136:3306: Access denied for user 'ic'@'192.168.1.164' (using password: NO) (1045)
   The command '/bin/sh -c mysqlrouter --bootstrap ic@192.168.1.136:3306 -d myrouter' returned a non-zero code: 1

步骤5/6中,我需要输入密码,但我不知道如何在文件中传递密码。有什么建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-03-12 08:08:42

最后,我找到了解决办法。这里我使用shell脚本文件来传递密码。

这是我的码头文件

代码语言:javascript
复制
FROM ubuntu:16.04
    RUN apt-get update && apt-get install -y wget && \
        wget https://dev.mysql.com/get/Downloads/MySQL-Router/mysql-router_2.1.6-1ubuntu16.04_amd64.deb && \
        apt-get install -y ./mysql-router_2.1.6-1ubuntu16.04_amd64.deb && \
        apt-get update && \
        apt-get install mysql-router && \
        useradd -ms /bin/bash router
    USER router
    WORKDIR /home/router
    COPY script.sh /script.sh
    RUN /script.sh
    CMD ["myrouter/start.sh"]

这是我的script.sh文件

代码语言:javascript
复制
#!/bin/bash
mysqlrouter --bootstrap ic@192.168.1.136:3306 -d myrouter <<< "password"
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49192217

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档