Open kadrach opened 7 years ago
Are you sure this is something that's provided by this image? I haven't checked but I highly doubt it.
If anything it's probably something that Docker itself adds
Confirmed – there's no /dev/shm
in the image:
curl -s https://lambci.s3.amazonaws.com/fs/nodejs4.3.tgz | tar -t | grep '^dev/'
dev/
dev/stdout
dev/null
dev/random
dev/full
dev/urandom
dev/zero
dev/stderr
dev/stdin
It appears that Docker adds this when it creates a container (ie, when you docker run
) – see the reference here:
https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources
Specifically the --shm-size
arg:
Size of /dev/shm. The format is
. number must be greater than 0. Unit is optional and can be b (bytes), k (kilobytes), m (megabytes), or g (gigabytes). If you omit the unit, the system uses bytes. If you omit the size entirely, the system uses 64m.
Given that it must be greater than zero there doesn't seem to be a way to run a container without Docker adding it. You could specify it as one byte – that might have a similar effect? Or you'll have to rely on the complicated unmounting procedure you outlined.
In any case, I don't think there's anything that can be done about the image itself on this front
I will give that a go, thanks for the quick follow up @mhart !
@kadrach any success on this front?
I ran into an issue earlier tonight trying to run chrome headless on lambda. It worked perfectly on the docker container but chrome never launched on lambda until I tracked down that lambda doesn't have /dev/shm
with chrome 64+ --disable-dev-shm-usage
moves from /dev/shm
to /tmp
. Could these images also restrict /dev/shm
to not exist? like the real lambda environment?
Here are some things I tried which do not work:
FROM lambci/lambda:build-python3.8
RUN rm -rf /dev/shm
Permission error because we're not root (but we are)
FROM lambci/lambda:build-python3.8 as src
RUN echo "abc" > /file.dat
FROM lambci/lambda:build-python3.8 as main
COPY --from=src /file.dat /dev/shm
Nope, once again docker build discards the changes to /dev/shm.
I think it's not specific to /dev/shm, and actually docker ignores changes to /dev
.
--shm-size=0
Running with --shm-size=0
doesn't work. Docker ignores a zero value
Maybe there's another way to emulate multiprocessing.Pool failing? (e.g. some global python config?) I'm not sure what would do that though. I looked through the relevant cpython code. I'm not sure where exactly the error is thrown. Maybe here?
--ipc=none
works for me.
The Lambda environment unfortunately does not have a tempfs mounted on
/dev/shm
, but it is provided by this image.I can manually fix this by running the container with
--privileged
, reinstallingutil-linux
(because/bin/mount
is missing) and unmounting/dev/shm
.Python's
multiprocessing
module uses/dev/shm
extensively and does not work properly in AWS Lambda, this is not fully replicated in this docker image.See issue on AWS forums.
However, this still runs on docker-lambda, but not on AWS Lambda: