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 :)
If running elevated Docker commands does not fix the permission denied error, verify that your Docker Engine is running. Similar to running a docker command without the sudo command, a stopped Docker Engine triggers the permission denied error. How do you fix the error? By restarting your Docker engine.
Fix 1: Run all the docker commands with sudo If you have sudo access on your system, you may run each docker command with sudo and you won't see this 'Got permission denied while trying to connect to the Docker daemon socket' anymore.
Docker containers are designed to be accessed as root users to execute commands that non-root users can't execute. We can run a command in a running container using the docker exec. We'll use the -i and -t option of the docker exec command to get the interactive shell with TTY terminal access.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With