1

how do we create a user inside a container using python docker apis? I am just running this but I am having errors to write to the home directory of the user. I am getting permission errors....

contCIS = cli.runContainer(buildImage, './MysqlScript.sh',
                                                network='bridgecontainers',
                                                volumes={os.getcwd(): {'bind': '/Build/', 'mode': 'rw'}, '/Users/rg/.m2/': {'bind': '/tmp/.m2/', 'mode': 'rw'}}, user=501, detach=True)

I am seeing errors like this below

linux spec user: unable to find user jenkins: no matching entries in passwd file

or is there a way to mount current user into container on a mac host ?

user2511126
  • 620
  • 1
  • 14
  • 31
  • Please add the error message to your question – Mostafa Hussein Mar 04 '19 at 07:59
  • The Docker APIs don't have any way to create users or otherwise change the filesystem inside containers before they start. I think the usual solutions involve an entrypoint script that gets the host user identity passed as a parameter. Given how much you're having to work around Docker's core design in this setup, also consider just using the `subprocess` module to run your build tool and leaving Docker out of it. – David Maze Mar 04 '19 at 11:44
  • or is there a way to mount current user into container on a mac host ? – user2511126 Mar 04 '19 at 12:36

0 Answers0