Azure DevOps with self-hosted Ubuntu machine: docker fails - docker

I created an Azure DevOps agents based on the Ubuntu image that can be found here: https://github.com/Microsoft/azure-pipelines-image-generation
After I deployed the machine and installed the agent (see https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-linux?view=vsts) I ran a Docker task and got the following error:
dial unix /var/run/docker.sock: connect: permission denied
What do I have to do to get the Docker task executed successfully?

The problem is that the agent service has not the permissions to connect. You can either run the agent service as root (sudo ./svc.sh install root) what I would not recommend or add the user to the Docker group via sudo usermod -a -G docker $USER.
Then logout and and log in again and it should work.
See also https://docs.docker.com/install/linux/linux-postinstall/

Related

Jenkins agent on GKE failed to run docker dial unix /var/run/docker.sock: connect: permission denied

I'm running Jenkins helm on GKE standard cluster with Container-Optimized OS with Docker (cos) image.
I'm running jenkins agent with docker installed and jenkins user added to docker group. I'm mounting /var/run/docker.sock as volume .. also tried t run with UID 1000.
-v /var/run/docker.sock:/var/run/docker.sock
But still getting dial unix /var/run/docker.sock: connect: permission denied ?! Any idea what I'm missing here ?
In addition to #again comment, below are possible reasons to look for regarding pemission denied error:
Docker is not installed on host
UID 1000 does not have permission to /var/run/docker.sock (try to chmod 777 the file temporarily and reduce permssion as needed)
Check Host and Container docker ID, must have the same UID
Also, you can refer on related links below for possible answers.
Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
Run Docker as jenkins-agent, in a docker-container, as non-root user
Use docker inside docker with jenkins user #263
docker.sock permission denied

Docker commands are running in console with Jenkins user but not within the pipeline

Docker commands are running in console with Jenkins user but not within the pipeline
I have a Jenkins inside ubuntu 14.04, I installed Docker as a service and I added Jenkins user to the docker group with the command sudo usermod -a -G docker jenkins, everything was fine, I ran docker commands in the console but when I run docker commands within a pipeline it says:
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.38/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&session=csxn4dmmf5v1ex0s7f83bhr62&shmsize=0&t=192.168.0.1%3A5000%2Fgo-app%3A14&target=&ulimits=null&version=1: dial unix /var/run/docker.sock: connect: permission denied
when I run id in concole it says:
uid=107(jenkins) gid=113(jenkins) groups=113(jenkins),998(docker)
and it is completely fine but when i run id whitin a pipeline it says
uid=107(jenkins) gid=113(jenkins) groups=113(jenkins)

Cannot connect to the Docker daemon on TeamCity build agent in AWS

I've got build agent machine on Amazon Linux AMI. It has docker container jetbrains/teamcity-agent:latest. I can see build agent in TeamCity panel.
When I'm trying to run build with docker build/push commands I'm getting this error
Cannot login to registry docker.io (new); cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?; exit code 1 (Step: docker build (Docker))
What's wrong with teamcity-agent?
I guess that the jetbrains/teamcity-agent:latest will be running as a user that does not have docker permissions. Either the user that runs the commands in this image needs to be added to the group docker, or via ACLs be given permission to the docker socket /var/run/docker.sock. Note that this is root-equivalent.

Openshift (oc) login to registry keeps on failing - how to start the Docker daemon?

After starting a command prompt, I normally start with login in to openshift with this command:
$ oc login https://api.starter-us-west-1.openshift.com
--token=
Works fine. Up till now I then connected to the docker registry of Openshift with the command:
$ docker login -u myOpenShiftName -p registry.starter-us-west-1.openshift.com (or :443)
Now I get this error (partly translated):
Warning: failed to get default registry endpoint from daemon (error
during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.37/info:
open //./pipe/docker_engine: The system cannot find the specified
file. In the default daemon configuration on Windows, the docker
client must be run elevated to connect. This error may also indicate
that the docker daemon is not running.). Using system default:
https://index.docker.io/v1/
Do I need a local docker running?
UPDATE/ANSWER: yes. On windows10 home start e.g. DockerQuickstartTerminal.
At another computer I had a similar error on Windows 10 pro with Docker. The service was started, but after I had started "Docker for Windows" the error disappeared.
My environment is Win10 home, virtual box + extension + docker toolbox.
The docker command cannot work without its local Docker daemon process running.
If you want to be able to work with OCI/Docker images and not need docker and the daemon, for some things you can use a tool like Skopeo.
https://github.com/containers/skopeo
There are also tools for building OCI container images which aren't dependent on docker.

docker create service unavailable

I am behind a corporate firewall, running on Windows 7. I believe that I have gotten past any proxy issues (at least as far as accessing the container for which I'm trying to install.)
At this point I'm trying to execute docker's run command which 'acquires' the tensorflow package an installs it on my system.
$ docker run -it -p 8888:8888 gcr.io/tensorflow/tensorflow
C:\Program Files\Docker Toolbox\docker.exe: An error occurred trying to connect:
Post https://192.168.99.100:2376/v1.23/containers/create: Service Unavailable.
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.
I'm new to docker, (obviously) but I see that the 192.168.99.100 default docker container exists and is running.
I do see documentation regarding the 'create' service endpoint. I'm at a dead end. Any help is appreciated.
-gene
when you type docker command docker client try to connect with your local docker service. And in linux world you need a superuser privileges to connect client and service.
I don`t run docker on windows, but may be you need run docker as Administrator. like linux
sudo docker run ...

Resources