2

Here is my docker file

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 [email protected]:3306 -d myrouter        CMD ["myrouter/start.sh"] 

This is Docker interactive Output:

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 [email protected]: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 [email protected]:3306 -d myrouter' returned a non-zero code: 1 

In Step 5/6 I need to Enter the Password but I don't no How to pass the  password in docker file. Any suggestions?

1
  • I know you can pass argument to your image with 'docker run' command.Or you can also use env variable which seems an even more common way. Commented Mar 9, 2018 at 11:14

1 Answer 1

2

Finally, I got the solution. Here I am using the shell script file to pass the password

This is my docker file

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"] 

This is my script.sh file

#!/bin/bash mysqlrouter --bootstrap [email protected]:3306 -d myrouter <<< "password" 
Sign up to request clarification or add additional context in comments.

1 Comment

RUN /script.sh is not required, you already copied your script.sh inside the image

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.