How to edit a dockerfile to build image of db2,and when container start could init database and tables;
FROM ibmcom/db2:latest
COPY init.sql /home/db2inst1/
COPY init_db.sh /home/db2inst1/
ENV DB2INST1_PASSWORD=password
ENV LICENSE=accept
RUN chmod +x /home/db2inst1/init_db.sh
CMD ["/home/db2inst1/init_db.sh"]
# init_db.sh
#!/bin/bash
su - db2inst1 -c "db2start"
su - db2inst1 -c "db2 -tvf /home/db2inst1/init.sql"
The Result is that the command “su – db2inst1 -c “db2 -tvf /home/db2inst1/init.sql” ” not effect
New contributor
xywei is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.