Reputation: 45118
(I am rewriting this question from another site to get more attention, I hope it is ok.)
I am trying to setup a Db2 developer environment following instruction from https://store.docker.com/images/db2-developer-c-edition.
I am able to create the container, start it and do even some sql queries
mkdir docker_volume
# I use the same env_list as the instructions link above
docker run -h db2server_myDb \
--name db2server \
--restart=always \
--detach \
--privileged=true \
-p 50000 \
--env-file .env_list \
-v docker_volume:/database \
store/ibmcorp/db2_developer_c:11.1.2.2
docker exec -ti db2server bash -c "su db2inst1"
db2 connect to testdb
db2 "create table t_project ( code varchar(5), name varchar(60) )"
db2 "insert into t_project (code, name) values (57003, 'sample')"
db2 "select * from t_project"
So far everything seems ok.
I am NOT able to connect to db from the host. How can I connect to this db from my macos machine? I am trying host: 172.17.0.1
port: 50000
Database: testdb
username: db2inst1
password: password
After stopping the container I am NOT able to start it again. What is the correct command to start or stop my db2 container?
$ docker stop db2server
$ docker start -ia db2server
(output)
...
DB2 State : Operable
DB2 has not been started
Starting DB2...
01/26/2018 03:21:38 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
mkdir: cannot create directory '/var/log/supervisor': File exists
Unlinking stale socket /var/run/supervisor.sock
(*) All databases are now active.
(*) Setup has completed.
false
2018-01-26-03.21.38.860516+000 I342573E395 LEVEL: Warning
PID : 629 TID : 140077563770752 PROC : db2start
INSTANCE: db2inst1 NODE : 000
HOSTNAME: db2server_myDb
FUNCTION: DB2 UDB, base sys utilities, sqleReleaseStStLockFile, probe:15795
MESSAGE : Released lock on the file:
DATA #1 : String, 50 bytes
/database/config/db2inst1/sqllib/ctrl/db2strst.lck
I am stuck here and I need to terminate the process and remove the container and re-do everything again.
Any help is highly appreciated
Upvotes: 1
Views: 1711
Reputation: 11052
You are using the Docker Store image of DB2 Developer-C. If you following the instructions for creating the container, you will notice that the instructions specify to use the option -p 50000
for docker run
. This option specifies that port 50000 in the container will be bound to a dynamic port on the host machine.
You need to check to see what port is attached on the host computer. You can see this in the output from docker ps
or, better, from docker port
:
$ docker port db2serverX
50000/tcp -> 0.0.0.0:32777
This shows that port 50000 in the container is mapped to port 32777 on (all) interfaces on the Docker host.
If you would like to specify the port you connect to on your Docker host, make sure to use the format -p 50000:50000
, where you are specifying hostPort:containerPort
.
Upvotes: 1