how to bring up a docker-compose container as privileged

Viewed 16767

I was running my container with the command sudo docker run --privileged container_name. But now I'm using a yml and and the command docker-compose up to bring it up but I don't know how to add the --privileged flag when bringing up the container with that command. I already tried adding privileged: true to the yml but it doesn't work in that case.

2 Answers

There is an apposite parameter to use:

web:
  image: an_image-image:1.0
  container_name: my-container
  privileged: true
  entrypoint: ["/usr/sbin/init"]
  ports:
    - "8280:8280"

I solved it myself by doing the following: in the docker-compose.yml file I have these two lines for specifying the image and container's name

version: "3"
services:
  app:
    image: my_image
    container_name: my-container

so to run it with the --privileged flag I used the command: sudo docker run --privileged my-container

Related