Can't create container from image because of the platform conflection

I was having a problem to create a container on my mac because:

i am running Docker on an Apple Silicon Mac (ARM64 architecture), but my image is built for linux/amd64 (Intel/x86 architecture). This platform mismatch is causing the container to exit immediately with code 0.

the docker support team told me to :

The Solution

You have two options to resolve this:

Run the Image with Platform Emulation (Quick Fix)

Modify your docker-compose.yml to include the platform specification:

services: integrationtoolkit.api: platform: linux/amd64 # ... rest of your configuration

The [platform attribute documentation] explains that this defines the target platform the containers run on using the os[/arch[/variant]] syntax.

Build a Multi-Platform or ARM64 Image (Recommended)

The better long-term solution is to build your image for ARM64 architecture. You can either:

  1. Build specifically for ARM64:docker build --platform linux/arm64 -t your-image-name .
  2. Build a multi-platform image that works on both architectures:docker buildx build --platform linux/amd64,linux/arm64 -t your-image-name .

Try Option 1 first by adding platform: linux/amd64 to your service in the docker-compose.yml file, then run:

docker compose up -d

And what i done :
I have tried to build a container from a docker.compose.yml file as follows :

1 first by adding platform: linux/amd64 to your service in the docker-compose.yml file

then Run :

docker compose up -d

I Got :

% docker compose up -d

[+] Running 1/1

:check_mark: integrationtoolkit.api Pulled 9.8s

[+] Running 1/1

✘ Container ecommerce Error response from daemon: image with reference egyptiantaxauthority/integrationtoolkit.api:3.1.3 was found but do… 0.0s

Error response from daemon: image with reference egyptiantaxauthority/integrationtoolkit.api:3.1.3 was found but does not provide the specified platform (linux/amd6)

so it doesn’t work unfortunately

And I can’t use the following command also,

docker buildx build --platform linux/amd64,linux/arm64 

as it will tell me → no such file or directory as this is not a docker file it’s a docker.compose.yml

and i can’t for sure remove the compose.yml part and rename it to dockerfile only

so what to do please ???

The platform property is incomplete. It should be linux/amd64, not just linux/amd6.

oh how i couldn’t see that thanks bro i will see

i already done both → platform: linux/amd64 && platform: linux/arm64

but still the container keep restarting unfortunately


the image is intended towork onlyon linux/amd64 → but my system is arm64 Macos

what should i do more i am disparate please help me

can someone tell me how to use multi platform like the next line :slight_smile:

docker buildx build --platform linux/amd64,linux/arm64 

with this docker.compose.yme as the previous command is onlyused with docker file not the multiservice docker.compose.yml file

please any help??

This property is used from docker compose to make it pull (if not cached already) and run the container for this target platform. If the platform is different than you host, it will run it inside a vm that emulates the target platform. I doubt this is the problem

This command is not to run container. It is used to build the image for multiple target platforms. This is something only the image maintainer(s) can do. Unless you have access to the sources, and those sources include a Dockerfile, this is not an approach you can take.

It is more likely to be a problem that occurs when the container starts. Please check the container logs for errors. It must be terminating the container due to an error.

To prevent the container from restarting all the time, you might want to set restart: "no", deploy the compose project, check the container logs. Please also run this cli command and share the output: docker ps -a --no-trunc.

I just tried what happens if a container is create from the image egyptiantaxauthority/integrationtoolkit.api on a arm64 cpu;

PS C:\Users\metin> docker run -it egyptiantaxauthority/integrationtoolkit.api:3.1.3
Unable to find image 'egyptiantaxauthority/integrationtoolkit.api:3.1.3' locally
3.1.3: Pulling from egyptiantaxauthority/integrationtoolkit.api
4ab67df41972: Pull complete
e47c0ca2fc18: Pull complete
ebd6ab09f8b2: Pull complete
1d5252f66ea9: Pull complete
73142e9035e4: Pull complete
75b8c875f256: Pull complete
34208b1c112b: Pull complete
615785a9af88: Pull complete
dbcb8bcac119: Pull complete
57e202db4287: Pull complete
0d414652a50a: Pull complete
cbbf692d0e05: Pull complete
91c4be48c2b1: Pull complete
cbf3a3eaf87d: Pull complete
de020d1e2d3f: Pull complete
4f4fb700ef54: Pull complete
89cb7968c6f3: Pull complete
31a23b133a5d: Pull complete
73fdcb52702f: Pull complete
Digest: sha256:6adf83b144820ec6c100d4e01793208a695e0d921b4da0532be8c5204eb5b934
Status: Downloaded newer image for egyptiantaxauthority/integrationtoolkit.api:3.1.3
[09:26:30 FTL] Service IntegrationToolKit.Api stopped with error SQLite Error 14: 'unable to open database file'.
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 14: 'unable to open database file'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteConnectionInternal..ctor(SqliteConnectionStringBuilder connectionOptions, SqliteConnectionPool pool)
   at Microsoft.Data.Sqlite.SqliteConnectionPool.GetConnection()
   at Microsoft.Data.Sqlite.SqliteConnectionFactory.GetConnection(SqliteConnection outerConnection)
   at Microsoft.Data.Sqlite.SqliteConnection.Open()
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternal(Boolean errorsExpected)
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)
   at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteDatabaseCreator.Create()
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate(DatabaseFacade databaseFacade)
   at ETA.eReceipt.IntegrationToolkit.Infrastructure.Services.Persistence.LocalReceiptsDbContext.Migrate() in /src/IntegrationToolKit.Infrastructure/Services/Persistence/LocalReceiptsDbContext.cs:line 93
   at ETA.eReceipt.IntegrationToolkit.Api.Ioc.DependencyInjection.Migrate(IHost app) in /src/IntegrationToolKit.Api/Ioc/DbMigration.cs:line 12
   at Program.<<Main>$>g__CreateWebApplication|0_0(String[] args, <>c__DisplayClass0_0& ) in /src/IntegrationToolKit.Api/Program.cs:line 52
   at Program.<Main>$(String[] args) in /src/IntegrationToolKit.Api/Program.cs:line 11

This image requires configuration and maybe even existing files to be mounted into the container to work. Unless you know how to configure it, I doubt you will be able to run a container based on this image.

Update:
I think, I somehow found the docs for this image : Docker Container Config