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

How to run containers in privileged mode #123

Closed
kvz opened this issue Mar 2, 2014 · 17 comments
Closed

How to run containers in privileged mode #123

kvz opened this issue Mar 2, 2014 · 17 comments

Comments

@kvz
Copy link

kvz commented Mar 2, 2014

From my docker container I would like to mount a network share. I've tried samba, afs, and nfs, but I keep getting Operation not permitted.

Googling has led me to believe that my container would need to run in privileged mode (http://www.gluster.org/2014/02/running-glusterfs-inside-docker-container/)

With Docker one can do --privileged=true but I don't think I can pass this along from my fig.yml via a:

sabnzbd:
  build: ./sabnzbd
  command: /syzygy/run.sh
  privileged: true

As that throws a Unsupported config option for sabnzbd service: 'privileged'. It also isn't documented in the fig documentation. Any way to go around this? I would be happy with any solution that allows me to mount a network drive, right now I just think that requires priviledged but I might be wrong.

Might be worth mentioning that I'm using the 0.8.0 boot2docker osx install.

@kvz
Copy link
Author

kvz commented Mar 2, 2014

I changed this line to make it say privileged=True, but that did not make the Operation not permitted errors go away. Am I on a stray path?

@bfirsh
Copy link

bfirsh commented Mar 3, 2014

This is all in service.py. You'll want to add it as a supported option and pass it through to container.start(...) in start_container.

Thanks for your help!

@kvz
Copy link
Author

kvz commented Mar 3, 2014

I'd love to send a PR for this, but I'm not up to speed with Python and currently stuck trying to run my fork like this:

$ python fig/cli/main.py
Traceback (most recent call last):
  File "fig/cli/main.py", line 10, in <module>
    from .. import __version__
ValueError: Attempted relative import in non-package

I'm obviously doin' it very wrong - but I can't find any Getting Started docs for developers. If they exist can you point me to those? Or otherwise some brief instructions how to set up a local development environment, then I'll be happy to write up a markdown/blogpost so other newcommers can easily dive into development too.

@bfirsh
Copy link

bfirsh commented Mar 3, 2014

Best way to start is to clone the repo and run python setup.py develop. That'll install the dependencies and set up a symlink from your fig executable to the checkout of the repo.

Docs very welcome! Thanks for your help!

@kvz
Copy link
Author

kvz commented Mar 4, 2014

Created a PR this issue #132.
It fixes the problem for me so I'll close this issue.

If I have time I'll write up some docs for newcomers to python/fig wanting to help out and create a separate PR for that.

@kvz kvz closed this as completed Mar 4, 2014
@bfirsh
Copy link

bfirsh commented Mar 4, 2014

Thanks @kvz!

bfirsh added a commit that referenced this issue Mar 4, 2014
@gregwebs
Copy link

gregwebs commented Mar 4, 2014

Not sure what I am doing wrong.

fig --version
fig 0.3.1
sudo fig up -d e2e
Unsupported config option for selenium service: 'privileged'

@kvz
Copy link
Author

kvz commented Mar 4, 2014

Hey @gregwebs, the merged PR was about the documentation. #132 needed some more research and is still pending.

bfirsh added a commit that referenced this issue Mar 13, 2014
Add support for privileged containers #123
@andreagrandi
Copy link

Hi! As I'm having exactly the same problem, are there any news about when this PR will be merged :) ? Thanks!

@kvz
Copy link
Author

kvz commented Oct 22, 2014

This was merged already. To enable on your containers use:

my_service:
  privileged: true

@bitliner
Copy link

I am using fig 1.0.1

If I try to set privileged to true it is like it is not executed.

In other words:

  • my Dockerfile print a string to a file
  • normally, it throws /bin/sh: 1: cannot create /sys/kernel/mm/transparent_hugepage/enabled: Read-only file system
  • so I add privileged:true to fig.yml
  • but then same error happens while building the container

yuval-k pushed a commit to yuval-k/compose that referenced this issue Apr 10, 2015
Add a contributing page. Refs docker#123
Signed-off-by: Yuval Kohavi <[email protected]>
yuval-k pushed a commit to yuval-k/compose that referenced this issue Apr 10, 2015
This is required for mounting external volumes and
addresses errors such as `mount.nfs: Operation not permitted`

Be gentle, I don't normally use Python :)

Signed-off-by: Yuval Kohavi <[email protected]>
yuval-k pushed a commit to yuval-k/compose that referenced this issue Apr 10, 2015
Add support for privileged containers docker#123
Signed-off-by: Yuval Kohavi <[email protected]>
@lucaspottersky
Copy link

I'm facing the same issue as @bitliner

docker-compose version: 1.4.1
Docker version 1.7.0, build 0baf609

The error:

Step 3 : RUN echo fs.inotify.max_user_watches=524288 | tee -a /etc/sysctl.conf && sysctl -p
 ---> Running in f45a1b3634fd
fs.inotify.max_user_watches=524288
sysctl: setting key "fs.inotify.max_user_watches": Read-only file system
Service 'frontend' failed to build: The command '/bin/sh -c echo fs.inotify.max_user_watches=524288 | tee -a /etc/sysctl.conf && sysctl -p' returned a non-zero code: 255

docker-compose.yml:

frontend:
  privileged: true
  build: ./frontend/
  ports:
   - "4200:4200"
  volumes:
   - ./frontend:/usr/src/app

@dnephin
Copy link

dnephin commented Sep 21, 2015

privileged doesn't apply to the build phase. It's only applied to a running container. This is a restriction applied by docker, but it's not obvious from the docker-compose.yaml.

xulike666 pushed a commit to xulike666/compose that referenced this issue Jan 19, 2017
Add oom support to events
@tenager
Copy link

tenager commented Jan 29, 2018

I am experiencing similar issue with docker-compose.yml. I am getting "Ignoring unsupported options: privileged" message. Any idea how to apply --privileged: true in docker-compose file??

@Sispheor
Copy link

@tenager same for me.
I'm on Docker version 17.12.1-ce, build 7390fc6

@dedalozzo
Copy link

@tenager It might depend by your docker-compose.yml version. Since 3.3 it works and the option must be placed under the definition of the service you want to run in privileged mode.

sf314 added a commit to sf314/HomeSat that referenced this issue Nov 21, 2020
The following link provides the container with sufficient permissions
(i.e. root) to run CFS:
- docker/compose#123

This is the fix to resolve the following issues:
- "Call to CFE_SB_CreatePipe Failed"
- "Your queue depth may be too large for the OS to handle..."
@rakshak-t
Copy link

privileged doesn't apply to the build phase. It's only applied to a running container. This is a restriction applied by docker, but it's not obvious from the docker-compose.yaml.

Yep this ended up being the solution. Had to call from within the container and not the Dockerfile

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