Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runOracle.sh doesn't find /sys/fs/cgroup/memory.max if run during image build with buildkit enabled #2334

Closed
metaruslan opened this issue Apr 6, 2022 · 9 comments
Assignees

Comments

@metaruslan
Copy link

metaruslan commented Apr 6, 2022

I'm trying to build a Dockerfile with such contents:

FROM container-registry.oracle.com/database/enterprise:19.3.0.0

ARG ORACLE_SID
ARG ORACLE_PDB
ARG ORACLE_PWD
ARG ENABLE_ARCHIVELOG
ARG AUTO_MEM_CALCULATION

# Option to enable archivelog in pre-built database
ENV ENABLE_ARCHIVELOG=${ENABLE_ARCHIVELOG:-false}
ENV ORACLE_SID=${ORACLE_SID}
ENV ORACLE_PDB=${ORACLE_PDB}
ENV ORACLE_PWD=${ORACLE_PWD}
ENV AUTO_MEM_CALCULATION=${AUTO_MEM_CALCULATION:-false}

RUN $ORACLE_BASE/$RUN_FILE --nowait

(inspired by https://github.com/oracle/docker-images/blob/main/OracleDatabase/SingleInstance/extensions/prebuiltdb/Dockerfile )

I get

#10 0.217 cat: /sys/fs/cgroup/memory.max: No such file or directory
#10 0.218 Error: The container doesn't have enough memory allocated.
#10 0.218 A database container needs at least 2 GB of memory.
#10 0.218 You currently only have 0 MB allocated to the container.
#10 ERROR: executor failed running [/bin/sh -c $ORACLE_BASE/$RUN_FILE --nowait]: exit code: 1

OS: MacOS
Docker Desktop: Version 4.6.1 (76265)

This error goes away if I build with disabling buildking, i.e.
docker build . -t my-oracle-prebuilt --progress=plain
fails
DOCKER_BUILDKIT=0 docker build . -t my-oracle-prebuilt --progress=plain
succeeds

The error happens at this code in runOracle.sh

# Check whether container has enough memory
if [[ -f /sys/fs/cgroup/cgroup.controllers ]]; then
   memory=$(cat /sys/fs/cgroup/memory.max)
else
   memory=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)
fi

export ALLOCATED_MEMORY=$((memory/1024/1024))

# Github issue #219: Prevent integer overflow,
# only check if memory digits are less than 11 (single GB range and below)
if [[ ${memory} != "max" && ${#memory} -lt 11 && ${memory} -lt 2147483648 ]]; then
   echo "Error: The container doesn't have enough memory allocated."
   echo "A database container needs at least 2 GB of memory."
   echo "You currently only have $ALLOCATED_MEMORY MB allocated to the container."
   exit 1;
fi

Introduced here https://github.com/oracle/docker-images/pull/1963/files#diff-5edd4db81714f280480cefa83cd5f40251d40a810076f4e8958a62d0ae8b1f2a
within #1963
I can see with an additional "RUN ls /sys/fs/cgroup/" command in my Dockerfile that there is no memory.max file, i.e. here is the output:

#9 [6/7] RUN ls /sys/fs/cgroup/
#9 sha256:f7efdd20b5e7b563cde17346bb14e163a6bfb1ece7e03861164c360976e1bb50
#9 0.317 000-dhcpcd
#9 0.317 001-sysfs
#9 0.317 002-sysctl
#9 0.317 003-format
#9 0.317 004-extend
#9 0.317 005-mount
#9 0.317 006-metadata
#9 0.317 007-services0
#9 0.317 008-services1
#9 0.317 009-swap
#9 0.317 010-mount-docker
#9 0.317 011-bridge
#9 0.317 allowlist
#9 0.317 binfmt
#9 0.317 cgroup.controllers
#9 0.317 cgroup.max.depth
#9 0.317 cgroup.max.descendants
#9 0.317 cgroup.procs
#9 0.317 cgroup.stat
#9 0.317 cgroup.subtree_control
#9 0.317 cgroup.threads
#9 0.317 cpu.stat
#9 0.317 cpuset.cpus.effective
#9 0.317 cpuset.mems.effective
#9 0.317 devenv-service
#9 0.317 dhcpcd
#9 0.317 dns-forwarder
#9 0.317 docker
#9 0.317 http-proxy
#9 0.317 io.stat
#9 0.317 kmsg
#9 0.317 kubepods
#9 0.317 memory.stat
#9 0.317 podruntime
#9 0.317 procd-paused
#9 0.317 restricted
#9 0.317 systemreserved
#9 0.317 volume-contents
#9 DONE 0.3s

Is it a docker BuildKit problem/bug or can runOracle be modified to support BuildKit?

@bendodds
Copy link

I am also experiencing this issue. Is there a work-around?

@metaruslan
Copy link
Author

I am disabling buildkit for now
DOCKER_BUILDKIT=0 docker build . -t my-oracle-prebuilt
But I’m not aware of a workaround with still using buildkit.

@bendodds
Copy link

Thank you very much. I see now that was in your original post. I misunderstood when I read it. This fixed the issue for me.

@yunus-qureshi
Copy link
Member

Yes, please disable buildkit as a workaround until this is addressed

@abhisbyk
Copy link
Contributor

Currently docker buildkit does not support cgroups. (Ref). So, as a workaround buildkit needs to be disabled. I will see how can we address this from the code perspective. I will keep this thread updated.

@abhisbyk
Copy link
Contributor

@metaruslan Can you please latest changes and test. It should work even with DOCKER_BUILDKIT enabled.
Closing this issue for now. Please reopen if you face some problem. Thanks !

@metaruslan
Copy link
Author

@abhisbyk thank you! I'll let you know if my team has problems with it, but it may take a while when we get to it, since it's low priority given we are using the workaround.

@abhisbyk
Copy link
Contributor

Ok, no problems. Thank you.

@catull
Copy link

catull commented Jun 30, 2023

Solution for macOS with M1/M2:

Install colima - Containers in Lima.

Start colima with

colima start --arch x86_64 --cpu 4 --memory 6

Now you can run docker commands.

Good luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants