4

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.

edean
  • 498
  • 3
  • 11

2 Answers2

2

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).

horstwilhelm
  • 305
  • 1
  • 15
  • `DOCKER_DEFAULT_PLATFORM` gives exactly the behaviour described in the question. colima is a beautiful tool, I did not know. Thanks! Unfortunately, it fails for another reason. By the time writing, I helped myself out by using UTM in order to invoke qemu to emulate an x86 computer, which runs an amd64 Debian, using docker to run db2. Appreciate your efforts! – edean Apr 21 '22 at 18:31
  • It works for me™️ but I'll try to figure out whether there's anything additional you need to do. I run most of my commands in an x86 shell (ie `arch -x86_64 $SHELL`), maybe that's the difference? – horstwilhelm Apr 25 '22 at 07:35
  • Checked again and this not only works with our `docker-compose.yaml` but also when starting the container like this: `export DOCKER_DEFAULT_PLATFORM=linux/amd64 && docker run -it --name db2 -e DBNAME=testdb -e DB2INST1_PASSWORD=GD1OJfLGG64HV2dtwK -e LICENSE=accept -p 50000:50000 --privileged=true --platform=linux/amd64 ibmcom/db2`. In `docker-compose.yaml`, we did not specify platform. This still produces `(*) Fixing /etc/services file for DB2 ...` and a few other warnings but it works in the end. – horstwilhelm Apr 25 '22 at 15:59
  • You might need to [delete your image](https://stackoverflow.com/a/69839676/2677658): `docker image rm your_img` – horstwilhelm Apr 25 '22 at 16:06
  • Turns out, you're absolutely right. After pruning my workspace, the setup I built for reproducing the issue, actually works out! Without any changes made. So I expect, there must have happened some work under the hood, making the image work in linux/amd64 mode on macOS. Your answer is therefore beautifully correct and works like a charm by the time writing. (Colima and Docker for Desktop both just work the way intended finally ☺️) – edean Apr 25 '22 at 16:29
  • Sadly, I'm still seeing lots of `db2: command not found` after overriding the platform. I'm using podman, so that might be re-exposing whatever the issue was. – Holly Cummins Jul 01 '22 at 16:59
  • podman will have its own way of activating intel compatibility mode, just like Colima. I wasn’t able to find that with a quick search. You might be more successful but this will be the root cause. – horstwilhelm Jul 03 '22 at 11:28
1

db2 is not supported on ARM architecture, only theses Architectures are supported: amd64, ppc64le, s390x

https://hub.docker.com/r/ibmcom/db2

mshabou
  • 524
  • 3
  • 6
  • Docker supports running linux/amd64-images on ARM-Macs. Therefore, your answer does not add any value, unfortunately. Thanks, however for your effort. – edean Nov 30 '21 at 22:46
  • 1
    Docker is juste a container system, you still need binary compatibility to run the program, you can't run DB2 on ARM-Macs. – mshabou Nov 30 '21 at 22:54
  • As @mshabou says Docker is the platform where images can be run. Docker works well in ARM (I have a couple of them running), but the IBM unfortunately hasn't released any DB2 images for ARM. This answer is correct. +1 – The Impaler Dec 01 '21 at 02:50
  • @edean We should all try to be correct in our answers and I'm sure we all do. Mistakes happen. There's no need to be this aggressive about it. – Hans Kilian Dec 01 '21 at 08:07
  • 1
    @Hans Kilian, thanks for your comment, you're absolutely right. I'm sorry for being offended by people being wrong collectively. It's not their fault, they aren't informed. We all want to learn, and I want to contribute, instead of being toxic myself. I suggest having a look about the background of Docker Desktop for Mac. Especially have a look at this blog article: https://www.docker.com/blog/the-magic-behind-the-scenes-of-docker-desktop/ Thanks again for your efforts and please forgive my bad example of a reaction. We all do our best. – edean Dec 01 '21 at 08:14
  • 1
    @edean no probleme, i'm DB2 DBA and i'm frustrated too, not to be able to move to the new Macbook pro M1-PRO, because there is no correct way to run DB2 LABs on the M1. – mshabou Dec 01 '21 at 12:34
  • Would any of you know how we can contact IBM support about this? I've been looking all over but can't find anything else than the forums which don't seem to get official answers. – horstwilhelm Jan 27 '22 at 14:31
  • @horstwilhelm to contact the support you need a valid support contract, maybe you can start by post an issu in their github – mshabou Jan 27 '22 at 15:15
  • I wouldn't know any GitHub repo, other than the ones under https://github.com/ibmdb which does not include the Docker image. We don't have a support contract, it's one of our providers that is running the Db2 for us and it's not straightforward for us to file a ticket through them. I am currently trying but progress is slow. – horstwilhelm Jan 28 '22 at 08:41
  • 2
    IBM is finally looking into this: [IBM Community thread](https://community.ibm.com/community/user/hybriddatamanagement/communities/community-home/digestviewer/viewthread?GroupId=2983&MessageKey=bf84e57b-263a-4ba5-a925-f13530c70e00&CommunityKey=ea909850-39ea-4ac4-9512-8e2eb37ea09a) – horstwilhelm Feb 14 '22 at 08:26
  • 1
    Hi I do not know if this will help, I pull ibm_db2 image on m1 macbook by using this below command and it worked. export DOCKER_DEFAULT_PLATFORM=linux/amd64;docker pull ibmcom/db2 – Usman Iqbal Mar 04 '22 at 07:50