A working solution for Apple Silicon (in my case Apple M3) with Docker Desktop for ibmcom/db2 image.
Most important options to apply:
1. In Docker Desktop go to Settings -> General -> unselect "Use Rosetta for x86_64/amd64 emulation on Apple Silicon"
2. add ENV variable DOCKER_DEFAULT_PLATFORM=linux/amd64 by running the command in console `export DOCKER_DEFAULT_PLATFORM=linux/amd64` or add it directly before the container start command (as in examples bellow)
3. use `--platform=linux/amd64` setting when running docker container
4. use `--privileged=true` setting when running container, otherwise db2 lacks access to run starting scripts
To run the container:
```
export DOCKER_DEFAULT_PLATFORM=linux/amd64 && docker run -it --name db2 -e DBNAME=test -e DB2INST1_PASSWORD=testpwd -e LICENSE=accept -p 50000:50000 --privileged=true --platform=linux/amd64 ibmcom/db2
```
Second solution to use with docker-compose.yml:
```
version: '3.8'
services:
db2:
image: ibmcom/db2
platform: linux/amd64
privileged: true
environment:
- LICENSE=accept
- DB2INST1_PASSWORD=testpwd
- DBNAME=test
ports:
- "50000:50000"
container_name: db2
```
To run with docker-compose:
```
export DOCKER_DEFAULT_PLATFORM=linux/amd64 && docker-compose up
```
To login via DB client (for example Dbeaver) use these connection settings:
```
host: localhost
port: 50000
user: db2inst1
password: testpwd
database: test
```
Side notes that helped me finding the solution:
- remember to remove container between settings changes
- remember to remove volumes between settings changes
A working solution for Apple Silicon (in my case Apple M3) with Docker Desktop for ibmcom/db2 image.
Most important options to apply:
1. In Docker Desktop go to Settings -> General -> unselect "Use Rosetta for x86_64/amd64 emulation on Apple Silicon"
2. add ENV variable DOCKER_DEFAULT_PLATFORM=linux/amd64 by running the command in console `export DOCKER_DEFAULT_PLATFORM=linux/amd64` or add it directly before the container start command (as in examples bellow)
3. use `--platform=linux/amd64` setting when running docker container
4. use `--privileged=true` setting when running container, otherwise db2 lacks access to run starting scripts
To run the container:
```
export DOCKER_DEFAULT_PLATFORM=linux/amd64 && docker run -it --name db2 -e DBNAME=test -e DB2INST1_PASSWORD=testpwd -e LICENSE=accept -p 50000:50000 --privileged=true --platform=linux/amd64 ibmcom/db2
```
Second solution to use with docker-compose.yml:
```
version: '3.8'
services:
db2:
image: ibmcom/db2
platform: linux/amd64
privileged: true
environment:
- LICENSE=accept
- DB2INST1_PASSWORD=testpwd
- DBNAME=test
ports:
- "50000:50000"
container_name: db2
```
To run with docker-compose:
```
export DOCKER_DEFAULT_PLATFORM=linux/amd64 && docker-compose up
```
To login via DB client (for example Dbeaver) use these connection settings:
```
host: localhost
port: 50000
user: db2inst1
password: testpwd
database: test
```
Side notes that helped me finding the solution:
- remember to remove container between settings changes
- remember to remove volumes between settings changes