Installing the Db2 Community Edition Docker image on Windows systems

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

Use this procedure to install a Docker image of Db2 Community Edition on 64-bit versions of Windows 10 Pro, Windows 10 Enterprise, or Windows 10 Education. The procedure assumes that you have installed Docker Desktop on a Windows system, using the steps outlined in Install Docker Desktop on Windows.
Attention: Db2 Community Edition for Docker is intended for non-production use only.
The Db2 Community Edition Docker image has the following, pre-set limitations:
  • Memory limit: 16GB
  • Core limit: 4 cores

Procedure

  1. In Windows Explorer, navigate to your user directory and create a folder for your Docker installation.
    For example, C:\Users\<user name>\Docker.
  2. In your newly created Docker directory, create a text file titled env_list.txt. This file is referenced by the Docker run command when setting up your Db2 instance.
    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.

  3. With Docker running on your Windows system, open a command prompt and enter the following Docker command to pull the Db2 Community Edition Docker image from ICR:
    docker pull icr.io/db2_community/db2
  4. In Windows Explorer, return to your Docker folder, open the env_list.txt file and paste the following:
    LICENSE=accept
    DB2INSTANCE=db2inst1
    DB2INST1_PASSWORD=password
    DBNAME=testdb
    BLU=false
    ENABLE_ORACLE_COMPATIBILITY=false
    UPDATEAVAIL=NO
    TO_CREATE_SAMPLEDB=true
    REPODB=true
    IS_OSXFS=false
    PERSISTENT_HOME=false
    HADR_ENABLED=false
    ETCD_ENDPOINT=
    ETCD_USERNAME=
    ETCD_PASSWORD=
    where
    • LICENSE (mandatory field) accepts the terms and conditions of the Db2 Community Edition software contained in this image
    • DB2INSTANCE (mandatory field) specifies the Db2 Community Edition instance name
    • DB2INST1_PASSWORD (mandatory field) specifies the password of the Db2 Community Edition instance
    • DBNAME creates an initial database with the name provided (leave empty if no database is needed)
    • BLU sets BLU Acceleration for the Db2 Community Edition 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 (false)
    • PERSISTENT_HOME disables persistent storage for the home directory (used for Linux and macOS installs) (false)
    • 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 Community Edition instance
      • ETCD_PASSWORD specifies the password credential for ETCD. If left empty, it will use your Db2 Community Edition instance password
  5. Save the file.
  6. Open a command prompt and run the following Docker command to create your Db2 Community Edition instance:
    docker run -h db2server --name db2server --restart=always --detach --privileged=true -p  50000:50000 --env-file env_list.txt -v C:/Users/<user name>/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 Community Edition Docker image.
    After the docker run command is executed, it will take a couple of minutes for the container to finish setting up. Make note of the container ID as you will need to include it in the Docker logs command.
  7. Run the Docker logs command to tail the docker entry point script:
    docker logs -f <your_container_name>
    If the setup is successful, the logs display the message Setup has completed.
  8. Enter the following command to access the running Db2 Community Edition 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.txt file.
  9. You can now access the Db2 database that you defined in your env_list.txt file (testdb), or the SAMPLE and repodb databases (if you selected those options in your env_list.txt file)