Adarsh H D Dev
Adarsh H D Dev

Reputation: 618

Db2 docker container exited with error code 0

I am trying to run a DB2 docker container using docker-compose but the problem is the container is every time exited with error code 0. below is the docker compose file.

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"

I added the tty: true after seeing some solutions suggest in stackoverflow. But its not working for me below is the 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

not sure why the container is stopping even the log doesn't show anything. Does anyone how to keep the container up and running.

Thanks

Upvotes: 0

Views: 381

Answers (1)

Paulo Pedroso
Paulo Pedroso

Reputation: 3705

A container may exit 0 when it's done all processing. So if your /opt/db_create.sh script runs things and then it doesn't keep a process running (not in background - daemon) then it will exit.

Upvotes: 2

Related Questions