# Cannot prevent repeated precompilation in docker runtime

**URL:** <https://discourse.julialang.org/t/cannot-prevent-repeated-precompilation-in-docker-runtime/136606>\
**Category:** General Usage\
**Tags:** question, docker\
**Created:** [April 7, 2026, 3:27pm UTC](https://discourse.julialang.org/t/cannot-prevent-repeated-precompilation-in-docker-runtime/136606 "2026-04-07T15:27:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dopamine](https://avatars.discourse-cdn.com/v4/letter/d/e9a140/32.png) [@dopamine](https://discourse.julialang.org/u/dopamine)\
**Post date:** [April 7, 2026, 3:27pm UTC](https://discourse.julialang.org/t/cannot-prevent-repeated-precompilation-in-docker-runtime/136606/1 "2026-04-07T15:27:53Z")

</div>

Hello, I’m deploying a julia script via docker, and can’t seem to prevent precompilation during runtime, which is very expensive, time-wise.

So I observe that precompilation happens normally during the build time, but it always seems to repeat again during each runtime.

I’ve already tried a bunch of tricks (see below), and wondering if some kind of CPU architecture mismatch might be triggering this.

Any advice would be greatly appreciated.

```docker
FROM julia:1.12-bookworm

ENV JULIA_PROJECT=/app \
    JULIA_DEPOT_PATH=/usr/local/julia-depot \
    JULIA_NUM_THREADS=auto \
    JULIA_CPU_TARGET=generic \
    JULIA_PKG_PRECOMPILE_AUTO=0

RUN apt-get update && apt-get install -y --no-install-recommends \
    git \
    ca-certificates \
    bzip2 \
    coreutils \
    perl \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY Project.toml ./
RUN julia --project=/app -e 'using Pkg; Pkg.instantiate()'

COPY src ./src
COPY scripts/my_script.jl ./scripts/my_script.jl
RUN julia --project=/app -e 'using Pkg; Pkg.precompile(); using MyPackage'
RUN julia --project=/app --compiled-modules=existing --pkgimages=existing /app/scripts/my_script.jl --help

RUN useradd --create-home --uid 10001 appuser \
    && mkdir -p /workspace /output \
    && chown -R appuser:appuser /app /workspace /output /usr/local/julia-depot

USER appuser

ENTRYPOINT ["julia", "--project=/app", "--compiled-modules=existing", "--pkgimages=existing", "/app/scripts/my_script.jl"]
CMD ["--help"]

```

---

<div class="post-metadata">

**Author:** ![dopamine](https://avatars.discourse-cdn.com/v4/letter/d/e9a140/32.png) [@dopamine](https://discourse.julialang.org/u/dopamine)\
**Post date:** [April 8, 2026, 2:16pm UTC](https://discourse.julialang.org/t/cannot-prevent-repeated-precompilation-in-docker-runtime/136606/2 "2026-04-08T14:16:16Z")

</div>

ok, i confirmed the problem was the cpu architecture issue.  
solution is to set env with the following:

```bash
JULIA_CPU_TARGET=generic

```
