Skip to content
Advertisement

ibmcom/db2 docker image fails on m1

I’m having trouble setting up DB2 on macOS via Docker on my M1-Max MacBook Pro (32 GB RAM). I already had a look at this question, which might be related, however there is not a lot of information and I cannot exactly say, if it is about the exact same thing. I set up following docker-compose.yml:

version: '3.8'

services:
  db2:
    image: ibmcom/db2
    platform: linux/amd64
    container_name: db2-test
    privileged: true
    environment:
      LICENSE: "accept"
      DB2INSTANCE: "db2dude"
      DB2INST1_PASSWORD: "db2pw"
      DBNAME: "RC1DBA"
      BLU: "false"
      ENABLE_ORACLE_COMPATIBILITY: "false"
      UPDATEVAIL: "NO"
      TO_CREATE_SAMPLEDB: "false"
      REPODB: "false"
      IS_OSXFS: "true"
      PERSISTENT_HOME: "true"
      HADR_ENABLED: "false"
      ETCD_ENDPOINT: ""
      ETCD_USERNAME: ""
      ETCD_PASSWORD: ""
    volumes: 
       - ~/workspace/docker/db2-error/db2/database:/database
       - ~/workspace/docker/db2-error/db2/db2_data:/db2_data
    ports:
      - 50000:50000

on my Intel-MacBook, this spins up without any issue, on my M1-MacBook however I see after Task #4 finished, I see following portion inside of the STDOUT:

DBI1446I  The db2icrt command is running.


DBI1070I  Program db2icrt completed successfully.


(*) Fixing /etc/services file for DB2 ... 
/bin/bash: db2stop: command not found

From what I could figure out, the presence of (*) Fixing /etc/services file for DB2 ... already seems to be wrong (since it does not appear in my intel log and does not sound like everything’s fine) and the /bin/bash: db2stop: command not found appears due to line 81 of /var/db2_setup/include/db2_common_functions, which states su - ${DB2INSTANCE?} -c 'db2stop force'. As far as I understand, su - should run with the path of the target user. In every single .profile or .bashrc in the home directory, the ~/sqllib/db2profile is being sourced (via . /database/config/db2dude/sqllib/db2profile).

However, when as root inside of the container (docker exec -it db2-test bash), calling su - db2dude -c 'echo $PATH', it prints /usr/local/bin:/bin:/usr/bin. Therefore, the PATH obviously is not as expected.

Maybe someone can figure out, what’s happening at this point. I also tried running Docker with “new Virtualization framework”, which did not change anything. I assume, Dockers compatibility magic might not be perfect, however I’m looking forward to find some kind of workaround, maybe by building an image upon ibmcom/db2.

I highly appreciate your time and advice. Thanks a lot in advance.

Advertisement

Answer

As stated in @mshabou’s answer, there is no support yet. One way you can still make it work is by prepending your Docker command with DOCKER_DEFAULT_PLATFORM=linux/amd64 or executing export DOCKER_DEFAULT_PLATFORM=linux/amd64 in your shell before starting the container.

Alternatively, you can also use colima. Install colima as described on their GitHub page and then start it in emulated mode like colima start --arch x86_64. Now you will be able to use your ibmcom/db2 image the way you’re used to (albeit with decreased performance).

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement