5.2.2 Docker exec command
The docker exec command runs a shell command inside the container, which can be used to log into the container environment, for example, to set up a command window inside the docker db2 container as illustrated in Figure 5.4:
docker exec -it mydb2 bash
su – db2inst1
db2licm -l
Figure 5.4: The docker exec -it mydb2 bash command is executed to run bash inside the newly installed DB2 container
The command as follows gives the list of DB2 components installed on the container:
db2ls -p -q -b /opt/ibm/db2/V11.5
5.2.3 Docker ps command
The docker ps command shows the list of containers installed on the system. In the IBM FileNet CPIT system, the command $docker ps is used to make sure the following docker containers are up and running:
• ldap
• db2
• cpe
• icn
This listing is shown in Figure 5.5 which shows the version and Container Identity of each of the containers used by IBM FileNet:
Figure 5.5: The docker ps command shows the list of containers running and their status
It can also be used to provide the Docker $containerID environment variable reference:
export DB2_CONTAINER_NAME=db2
export containerID=
‘
docker ps -a -q –filter name=$DB2_CONTAINER_NAME$
‘
The environment variable $DB2_CONTAINER_NAME$ contains the name of the container (db2 in the above example) and this is used to retrieve the actual ID using a docker ps command, which can then be used to access files from the container back to the host server.
In the following example, the create table script file, 01_createTables.sql is copied to the container server db2 path $containerID:/database/config/db2inst1 from the host path:/opt/ibm-cloud-private-3.2.0/cluster/db2_graph/data/.
The docker command used is:
docker cp /opt/ibm-cloud-private-3.2.0/cluster/db2_graph/data/01_createTables.sql
$containerID:/database/config/db2inst1