How to fix docker: Got permission denied issue
If you want to run docker as non-root user then you need to add it to the docker group.
- Create the docker group if it does not exist
$ sudo groupadd docker
- Add your user to the docker group.
$ sudo usermod -aG docker $USER
- Log in to the new
docker
group (to avoid having to log out / log in again; but if not enough, try to reboot):
$ newgrp docker
- Check if docker can be run without root
$ docker run hello-world
Reboot if still got error
$ reboot
Warning
The docker group grants privileges equivalent to the root user. For details on how this impacts security in your system, see Docker Daemon Attack Surface..
Taken from the docker official documentation:
manage-docker-as-a-non-root-user
Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
If using jenkins
The user jenkins
needs to be added to the group docker
:
sudo usermod -a -G docker jenkins
Then restart Jenkins.
Otherwise
If you arrive to this question of stack overflow because you receive this message from docker, but you don't use jenkins, most probably the error is the same: your unprivileged user does not belong to the docker group.
You can do:
sudo usermod -a -G docker [user]
Insert your user name where [user]
is.
You can check it was successful by doing grep docker /etc/group
and see something like this:
docker:x:998:[user]
in one of the lines.
Then change your users group ID to docker
(to avoid having to log out and log in again):
newgrp docker
getting permission denied in docker run
You need to change the permission of the bash file by chmod +x entrypoint.sh
before calling ENTRYPOINT. So change your code to the following:
USER airflow
WORKDIR ${AIRFLOW_HOME}
RUN chmod +x entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
Rebuild the image and run the container, it should work.
docker.errors.DockerException: Error while fetching server API version or Permission denied error
Figured it out we need to add this to docker-compose file and give right permission to it below
- //var/run/docker.sock:/var/run/docker.sock
sudo chmod 666 /var/run/docker.sock
This is how common-part of docker-compose file looks like now:
volumes:
- ./dags:/opt/airflow/dags
- ./logs:/opt/airflow/logs
- ./plugins:/opt/airflow/plugins
- //var/run/docker.sock:/var/run/docker.sock
Related Topics
Vs Code Ssh Remote Connection Issues
Stdin into Zip Command, How to Specify a File Name
What Is Eof!! in The Bash Script
Checking Shared Libraries for Non Default Loaders
Get Unique Serial Number of Usb Device Mounted to /Dev Folder
How to Allow Jenkins to Access The Files That Only Root or Some Specific Programs Have Access To
Execute Bash Script Remotely via Curl
How to Diagnose a Python Process Chewing CPU in Linux
Copy Lines Containing Word from One File to Another File in Linux
Find Which Program Caused a Core Dump File
How to Use Systemd to Restart a Service When Down
Sudo User Not Using Same Node Version
How to Programmatically Invert Screen Colors in Linux
What Is The Linux Equivalent to Msvc++'s Option /D1Reportsingleclasslayout