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

Add support for --shm-size docker run flag #787

Closed
aaithal opened this issue May 3, 2017 · 23 comments
Closed

Add support for --shm-size docker run flag #787

aaithal opened this issue May 3, 2017 · 23 comments

Comments

@aaithal
Copy link
Contributor

aaithal commented May 3, 2017

Has 7 +1s and the following mentions:

@sdeprez
Copy link

sdeprez commented May 17, 2017

Hi ,

Any ETA for this feature? Or any workaround for it in the meantime?

Basically, I need to run some version of Chromium headless inside containers, and that requires more than the default 64M of shared memory so at the moment it's simply impossible to run it.

Actually a quick but probably dirty hack is to mount the /dev/shm of the container to the /dev/shm of the container instance in your task definition. The equivalent in docker run would be:
docker run -v /dev/shm:/dev/shm. Use with caution, it may have some side effects I'm not aware of.
Another workaround is to run docker in privileged mode and manually increase the shared memory size from inside, see https://bugs.chromium.org/p/chromium/issues/detail?id=519952#c6.

Thanks,

@csvan
Copy link

csvan commented Jun 15, 2017

+1, also running Chromium inside ECS here. Next to impossible with default shm size.

@linuxfreakus
Copy link

+1, ditto on headless chromium.

@matthew-cox
Copy link

+1, I would really prefer support for this option vs implementing the possible work arounds

@trstephen
Copy link

+1, headless chromium is a shrinking violet with default 64mb shm

@AlexMarchini
Copy link

+1, also stuck until this is implemented.

@mkleint
Copy link

mkleint commented Aug 4, 2017

we are also waiting for the Amazon ECS AMi to contain latest docker daemon to at least be able to change the default size of shm to be bigger than 64M

@alinpa
Copy link

alinpa commented Aug 23, 2017

+1, I am waiting to see this feature implemented.
Did anyone find any workaround for this issue?

@zackarychapple
Copy link

Any update on when this will be a reality? We are running into issues on this as well.

@tobypinder
Copy link

tobypinder commented Sep 12, 2017

@alinpa we use

"Volumes": [
    {
      "HostDirectory": "/dev/shm",
      "ContainerDirectory": "/dev/shm"
    }
  ],

in the Dockerrun.aws.json to effectively hand the host's shm to the guest container. I am unclear of any side effects here but it appears to work well for our single container environment. I'm not an expert but you and others here may find this a suitable workaround and we haven't noticed any issues arising from this yet.

EDIT: I should mention to aid understanding that this is the exact equivalent of @sdeprez's approach, for AWS instead of docker run on a local machine.

@aatreya
Copy link

aatreya commented Sep 15, 2017

Anyone interested in this for use with Chrome/Chromium may also want to star / comment on these bugs:
https://bugs.chromium.org/p/chromium/issues/detail?id=715363
https://bugs.chromium.org/p/chromium/issues/detail?id=736452

@zackarychapple
Copy link

zackarychapple commented Sep 15, 2017

This article is amazing https://medium.com/@marco.luethy/running-headless-chrome-on-aws-lambda-fa82ad33a9eb as it shows how to remove the requirement on shm with a custom binary.

@linuxfreakus
Copy link

Yes, its pretty cool, but if you're having SHM issues already with chromium, they are likely to continue with lambda. You can force it to run in that environment, but when I tried, it didn't work for our purposes. Very crashy.

@linuxfreakus
Copy link

FWIW, we currently hack it by granting elevated privileges and remounting /dev/shm on container boot. Not optimal, especially if you have strong security requirements, but one of the only ways to safely make it happen from a memory allocation standpoint if you use more than one container. Other than that, you have to give up ECS and roll your own.

@mrzacarias
Copy link

I'm trying to use Google Puppeteer on ECS and I'm having this problem. I'm using Fargate as well, so there's no way to use the privileged mode hack...

Do you have an ETA for that? That's keeping me and my team away of using cool stuff like ECS...

@mkleint
Copy link

mkleint commented Dec 13, 2017

FYI on latest Amazon ECS AMIs (or any AMI with docker 17.06+) it's possible to increase the size of /dev/shm by passing --default-shm-size 256M to the docker daemon on startup.

@mrzacarias
Copy link

mrzacarias commented Dec 14, 2017

@mkleint That are great news! I couldn't find the documentation about this option, do you have any source explaining how to use this?

@stephen
Copy link

stephen commented Dec 14, 2017

From reading the latest in https://bugs.chromium.org/p/chromium/issues/detail?id=736452#c56, it looks like this issue is fixed in Chrome >= 64.0.3281.0 with a --disable-dev-shm-usage flag.

@mkleint
Copy link

mkleint commented Dec 14, 2017

@mrzacarias moby/moby#29692 https://docs.docker.com/enterprise/17.06/

@sharanyad
Copy link
Contributor

A proposal for the implementation of shmsize is available in #1149.

sharanyad added a commit to sharanyad/amazon-ecs-agent that referenced this issue Jan 25, 2018
This commit contains the model changes and functional tests for the new Task Definition fields for shmsize and tmpfs.

This addresses the following issues:
* aws#787
* aws#469
sharanyad added a commit to sharanyad/amazon-ecs-agent that referenced this issue Jan 25, 2018
This commit contains the model changes and functional tests for the new Task Definition fields for shmsize and tmpfs.

This addresses the following issues:
* aws#787
* aws#469
@aaithal
Copy link
Contributor Author

aaithal commented Mar 20, 2018

Hello everyone, we announced support for shm-size parameter in the task definition today! Please refer to our documentation for more details.

Closing this issue for now. Please let us know if you have any follow up comments/questions regarding this.

@aaithal aaithal closed this as completed Mar 20, 2018
sharanyad added a commit that referenced this issue Mar 20, 2018
This commit contains the model changes and functional tests for the new Task Definition fields for shmsize and tmpfs.

This addresses the following issues:
* #787
* #469
@robertorocha3
Copy link

@aaithal have you added this option to cloudformation? I don't see it in here:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-taskdefinition-linuxparameters.html
If not, do you have a recommended workaround for this?

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

No branches or pull requests