db2 docker容器退出,错误代码为0

时间:2018-08-10 07:25:57

标签: docker docker-compose

我正在尝试使用docker-compose运行一个DB2 docker容器,但是问题是该容器每次都退出,错误代码为0。下面是docker compose文件。

version: "2"
services:
 db:
  container_name: db2
  image: ibmcom/db2express-c:latest
  environment:
    DB2INST1_PASSWORD:  samplepassword!
    LICENSE: accept
  ports:
    - "50000:50000"
  tty: true
  volumes:
    - "./db_create.sh:/opt/db_create.sh"
  command:
    - "/opt/db_create.sh"

看到堆栈溢出中提出了一些解决方案后,我添加了tty: true。但是下面对我来说不起作用的是docker log

Starting db2 ... done
Attaching to db2
db2   | Changing password for user db2inst1.
db2   | New password: Retype new password: passwd: all authentication tokens updated successfully.
db2   | libnuma: Warning: /sys not mounted or invalid. Assuming one node: No such file or directory
db2   | SQL1063N  DB2START processing was successful.
db2   | 
db2   |   Creating database "SLIM"...
db2   |   Existing "SLIM" database found...
db2   |   Dropping and recreating database "SLIM"...
db2   |   Connecting to database "SLIM"...
db2   |   Creating tables and data in schema "DB2INST1"...
db2   |   Creating tables with XML columns and XML data in schema "DB2INST1"...
db2   | 
db2   |   'db2sampl' processing complete.
db2   | 
db2 exited with code 0

不知道容器为什么停止,即使日志什么也没显示。有谁能保持容器正常运行?

谢谢

1 个答案:

答案 0 :(得分:1)

完成所有处理后,容器可能会退出0。因此,如果您的/opt/db_create.sh脚本运行了某些东西,但又没有使进程保持运行(不在后台-守护程序中),那么它将退出。