Run command as –privileged in Dockerfile

I need to bee –privileged to run a specific command in the Dockerfile but I can’t find a way to tell docker to do so.

The command is RUN echo core > /proc/sys/kernel/core_pattern

  • Docker Machine + Docker Compose + Volumes on Ubuntu
  • How to use stack image container?
  • Pushing a tag to private docker registry in artifactory fails from mac
  • Unable to ssh to master node in mesos local cluster installed system
  • Reverse proxy between a unicorn server and Galera cluster
  • How to remote debug python code in a Docker Container with VS Code
  • If I put that in the Dockerfile the build process fails.

    If I run the Dockerfile with that line commented but with the flag --privileged then I can run the command well within the container.

    Is there any solution to make everything work from the Dockerfile?

    Thank you

  • Does Calico work with Docker in Swarm Mode, If so what is the version?
  • ssh through container causes stdin: is not a tty
  • How to connect to service in the host machine from inside a docker container?
  • How to select file to copy based on Docker environment variable?
  • How to run application from docker container from host OS?
  • How do I create docker image from an existing CentOS?
  • One Solution collect form web for “Run command as –privileged in Dockerfile”

    Not exactly “Dockerfile”, but you can do this with an entrypoint script provided you always run the container with --privileged

    That being said, I would warn against this if at all possible as part of the beauty of docker is that you aren’t running things as root.

    A more better alternative, IMHO, is instead to change this on the host system. In that way, it will be reflected within the container as well.

    The only caveat to that is that that will be reflected on all containers on that system (and of course, the system itself).

    Here is a proof of concept for my suggested solution:

    root@terrorbyte:~# docker run -it alpine cat /proc/sys/kernel/core_pattern
    core
    root@terrorbyte:~# echo core2 > /proc/sys/kernel/core_pattern
    root@terrorbyte:~# docker run -it alpine cat /proc/sys/kernel/core_pattern
    core2
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.