0

I'm using docker engine api to build image and then create and run container. What I need is run container with --privileged flag. But I couldn't see anything in docker engine api reference doc.

https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate

const createContainerRes = await axios({
      method: 'post',
      url: 'http://localhost:2375/containers/create',
      headers: {
        'content-type': 'application/json',
      },
      data: {
        Image: imageName,
        HostConfig: {
          PortBindings: {
            '8333/tcp': [{ HostPort: port }],
          },
        },
      },
    })
      .then(res => {
        return res;
      })
      .catch(err => {
        resolve({ message: 'Error' });
      });

How can I start container with privileged flag with docker engine api ?

  • 1
    It's in the `HostConfig` section. – David Maze Jun 08 '20 at 10:46
  • I assume you've gotten the usual warning about allowing `http://localhost:2375` being incredibly dangerous, and any local process can launch a privileged container (or worse), and please don't have told Docker to allow external connections too? – David Maze Jun 08 '20 at 10:47
  • thank you for your answer @DavidMaze and sorry for not seeing it. My intention is write these with socket later. But problem with privileged is im trying to use docker in docker maybe you heard it and it only works with this way. And also yes my goal is open these container for external use :(. Is there anything i can co it this with different or more secure way ? thanks again for your answers. – ahmedsalihh Jun 10 '20 at 09:36

0 Answers0