2021-10-19
1486
#docker#flutter
Damilare Jolayemi
72066
Oct 19, 2021 ⋅ 5 min read

Containerizing Flutter web apps with Docker

Damilare Jolayemi Damilare is an enthusiastic problem-solver who enjoys building whatever works on the computer. He has a knack for slapping his keyboards till something works. When he's not talking to his laptop, you'll find him hopping on road trips and sharing moments with his friends, or watching shows on Netflix.

Recent posts:

react children prop how to properly type

How to type React children correctly in TypeScript

Learn modern best practices for typing React children in TypeScript, including ReactNode, PropsWithChildren, ComponentProps, and why React.FC is no longer recommended.

Ohans Emmanuel
Dec 19, 2025 ⋅ 7 min read
complete guide to internationalization next js

The complete guide to internationalization in Next.js

Learn how to internationalize Next.js apps with Lingui and next-intl, covering App Router, RSC, routing, locale detection, and dynamic language switching.

Ivan Vlatkovic
Dec 19, 2025 ⋅ 13 min read

Vite vs. Webpack for react apps in 2025: A senior engineer’s perspective

Vite vs Webpack in 2025: a senior engineer’s take on performance, developer experience, build control, and when each tool makes sense for React apps.

Peter Aideloje
Dec 19, 2025 ⋅ 3 min read
vitest 4 adoption guide

Vitest 4 adoption guide: Overview and migrating from Jest

Learn how Vitest 4 makes migrating from Jest painless, with codemods, faster tests, native ESM, browser testing, and a better DX.

Onuorah Bonaventure
Dec 18, 2025 ⋅ 15 min read
View all posts

9 Replies to "Containerizing Flutter web apps with Docker"

  1. Hi, thanks for the great explanation on how to run flutter in a container, but I need to add something.

    In the Dockerfile
    1.) You need to remove the 1st line from “sh”
    2.) Add these 2 lines to the Docker file
    ENV TZ=Europe/Warsaw
    RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

    This is necessary because apt-get wants to install the “libgconf-2-4” package and tzdata and we need to answer the question about TIMEZONE during installation/configuration. These 2 lines in the Dockerfile can configure TIMEZONE automatically.

    Of course, we can also run nginx as a replacement with “python3 -m http.server $PORT” but that’s another story 🙂

    1. After which line do we have to add the below line in Dockerfile?

      ENV TZ=Europe/Warsaw
      RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

  2. ERROR: while running ` docker build -t flutter_web_test . `

    => ERROR [ 3/14] RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc 1.1s
    ——
    > [ 3/14] RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback lib32stdc++6 python3:
    #6 0.329 Reading package lists…
    #6 0.934 Building dependency tree…
    #6 1.060 Reading state information…
    #6 1.108 E: Unable to locate package lib32stdc++6
    #6 1.108 E: Couldn’t find any package by regex ‘lib32stdc++6’
    ——
    executor failed running [/bin/sh -c apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback lib32stdc++6 python3]: exit code: 100

  3. answer to why it is not working on M1
    As you noticed yourself, you are starting a docker build based on an image that was built for another platform, i.e. you are running arm64 but the image is linux/amd64. This means that docker will run it but with an emulation layer, namely qemu.

    Some incompatibility between Dart and qemu seems to be the problem. In the stacktrace you posted, qemu crashed when Dart runtime tried to execute InvokeCode(). This is actually a reported problem, see e.g.

    dart-lang github issue: Building linux/amd64 Docker Image on Mac M1 (most relevant, I think)
    flutter github: build flutter(3.0.3) docker image base on ubuntu:18.04 crash
    another flutter issue: Unable to ‘pub upgrade’ flutter tool
    answer to what to do
    The Dart folks have no plans to analyze this any further since the problem lies with qemu and the problem was not reproduced with qemu outside docker.

    It is also noteworthy that docker with qemu is only provided as a best effort and the docker project itself is unlikely to tackle the issue either, even if reported.

    I did not find a filed issue for qemu itself.

    There are basically two options:

    Do the thing without qemu, meaning to build in a linux/arm64 container
    This will work to some degree regarding flutter, but the next thing you will have to tackle is arm-based android build for linux, which is a whole new can of worms. See e.g. google’s android bug tracker, Please support Linux aarch64 for building apps and others.

    Do the build without arm/M1 hardware
    As sad as it is to realize this, it might be the straightforward solution to not cross-build in this case, at least for flutter with android build target. And likely also a logical one if you want to provide an intel compatible docker image to coworkers and/or CI which might not run M1. Ultimately, it is a question what your reference build platform is.

  4. It was working fine, but for some reason now I always get this error:

    exec /app/server/server.sh: no such file or directory

    Does anyone have a solution for that?

  5. Following steps to much time run

    => [ 3/14] RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback l 735.5s
    => => # questions will narrow this down by presenting a list of cities, representing
    => => # the time zones in which they are located.
    => => # 1. Africa 4. Australia 7. Atlantic 10. Pacific 13. Etc
    => => # 2. America 5. Arctic 8. Europe 11. SystemV
    => => # 3. Antarctica 6. Asia 9. Indian 12. US
    => => # Geographic area:

    Any Idea why it takes to much time?

  6. The above docker file is build around 1.92 GB flutter mage. Is there any way to reduce that image size?

Leave a Reply

Hey there, want to help make our blog better?

Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.

Sign up now