DB2 in Docker results in DB21018E

做~自己de王妃 提交于 2019-12-11 17:44:19

问题


I can't build a Docker image with DB2.

Dockerfile:

FROM ibmcom/db2express-c

EXPOSE 50000
CMD ["db2start"]

SHELL ["/bin/bash", "-c"]
RUN su - db2inst1 -c "db2 create db DMX"

Log:

Building image...
Step 1/5 : FROM ibmcom/db2express-c

 ---> 7aa154d9b73c


Step 2/5 : EXPOSE 50000

 ---> Using cache

 ---> 3172f8b3790b


Step 3/5 : CMD ["db2start"]

 ---> Using cache

 ---> f38e27452920


Step 4/5 : SHELL ["/bin/bash", "-c"]

 ---> Using cache

 ---> 1cef61dbf3c5


Step 5/5 : RUN su - db2inst1 -c "db2 create db DMX"

 ---> Running in 59b7a5d1c0ba


DB21018E  A system error occurred. The command line processor could not 
continue processing.

Error: ResponseItem.ErrorDetail[code=8,message=The command '/bin/bash -c su 
    - db2inst1 -c "db2 create db DMX"' returned a non-zero code: 8]

But if I execute su - db2inst1 -c "db2 create db DMX" manually it works:

MB-54:test mkadan$ docker exec -i -t db2 /bin/bash
[root@5cb934e6d434 /]# su - db2inst1 -c "db2 create db DMX"
DB20000I  The CREATE DATABASE command completed successfully.

Any hint what's the problem here?


回答1:


The problem was indeed in bash environment not set up correctly. I resolved it by using the following RUN command:

RUN su - db2inst1 -c "/bin/bash && db2start && db2 create db DMX"

instead of the original one:

RUN su - db2inst1 -c "db2 create db DMX"



来源:https://stackoverflow.com/questions/52117273/db2-in-docker-results-in-db21018e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!