Permission denied inside Docker container

2019-04-19 10:04发布

问题:

I have a started container gigantic_booth and I want to create the directory /etc/test:

# docker exec -it gigantic_booth /bin/bash
$ mkdir /etc/test
$ mkdir: cannot create directory '/etc/test': Permission denied

And sudo command is not found. I don't want to create this directory in image-build-time but once is started.

How can I do?

Thanks :)

回答1:

Or just use docker exec -u thejenkinsuser.



回答2:

I'm using jenkins image and I have just read that it has root access disabled for security reasons. https://github.com/jenkinsci/docker#installing-more-tools

I have re-built the image with this Dockerfile:

FROM jenkins

USER root

and now it works properly, it is not so secure, though.



标签: docker