You can use the Db2® Community Edition
to quickly develop, test, and build applications to work with your business's operational and
analytic workloads.
About this task
This procedure can be used to install a Docker image of Db2 11.5.4 Community Edition on any of
the following 64-bit Linux desktop environments:
- Ubuntu versions 16.04 Long Term Support (LTS), 18.04 (LTS), 18.10, or 19.04,
- CentOS version 7.1 or higher
- Fedora versions 28 or 29
- Debian versions 9 or 10
The
Db2
Community Edition Docker image has the following usage limitations:
- Memory limit: 16GB
- Core limit: 4 cores
Procedure
-
From the command line, create a new directory for your Docker image:
- Go to this directory by entering the following command:
Note: Docker uses a configuration file,
config.json, for unencrypted storage of
credentials. As a result, prior to entering your username and password, you may receive the message,
WARNING: Error loading config file....
, followed by the expected default location
of the config.json file.
This
message will not prevent you from entering your credentials and accessing your Docker environment.
Once you have logged in, Docker creates a config.json file and stores your credentials in the file
at the default location. See docker login for information on creating secure storage of your Docker
credentials.
- Log into your Docker container:
- Pull the Db2 Docker image from ICR:
docker pull icr.io/db2_community/db2
- Create an environment variables file, .env_list, for your Db2 Community Edition
image:
- Paste the following into the environment variables file:
LICENSE=accept
DB2INSTANCE=db2inst1
DB2INST1_PASSWORD=password
DBNAME=testdb
BLU=false
ENABLE_ORACLE_COMPATIBILITY=false
UPDATEAVAIL=NO
TO_CREATE_SAMPLEDB=false
REPODB=false
IS_OSXFS=false
PERSISTENT_HOME=true
HADR_ENABLED=false
ETCD_ENDPOINT=
ETCD_USERNAME=
ETCD_PASSWORD=
where
- LICENSE accepts the terms and conditions of the Db2 software
contained in this image
- DB2INSTANCE specifies the Db2 instance
name
- DB2INST1_PASSWORD specifies the password of the Db2 instance
- DBNAME creates an initial database with the name provided (leave empty if no database is
needed)
- BLU sets BLU Acceleration for the Db2 instance to
enabled (true) or disabled (false)
- ENABLE_ORACLE_COMPATIBILITY sets Oracle compatibility on the instance to enabled (true)
or disabled (false)
- UPDATEAVAIL can be set to YES if there is an existing instance running a new container
with a higher Db2 level.
- TO_CREATE_SAMPLEDB creates a sample (pre-populated) database (true)
- REPODB creates a Data Server Manager repository database (true)
- IS_OSXFS identifies the operating system as macOS (true)
- PERSISTENT_HOME is set to true by default and should only specified as false when
running Docker for Windows
- HADR_ENABLED configures Db2 HADR for the
instance (true). The following three environment variables depend on HADR_ENABLED being set
to true:
- ETCD_ENDPOINT specifies your own provided ETCD key-value store. Enter your endpoints with a
comma (and no space) as the delimiter. This environment variable is required if HADR_ENABLED is set
to true
- ETCD_USERNAME specifies the username credential for ETCD. If left empty, it will use your
Db2
instance
- ETCD_PASSWORD specifies the password credential for ETCD. If left empty, it will use your
Db2 instance
password
- Save the file by pressing ESCAPE (ESC), and entering:
- Enter and run the following command to enter the Docker container:
docker run -h db2server --name db2server --restart=always --detach --privileged=true
-p 50000:50000 --env-file .env_list -v /Docker:/database icr.io/db2_community/db2
where
-h
assigns the name db2server to the Docker
container.
-p
specifies the port numbers to
use.
--privileged
starts the container in privileged
mode.
-v
defines the volume used for the Db2 Docker
image.
- Enter the following command to access the running Db2 instance within
your Docker container:
docker exec -ti db2server bash -c "su - db2inst1"
where
db2inst1 is the value associated with the
DB2INSTANCE variable
in your
.env_list file.
- You can now create a Db2 database within
the active instance.