Reputation: 423
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?
Upvotes: 2
Views: 355
Reputation: 423
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"
Upvotes: 2