Jenkins container in docker environment has insufficient permission to execute docker command prompt after entering.

  docker, question
    • After the docker pull-down takes jenkins image, it passes after build and run.docker exec it [containerID] /bin/bashAfter the command enters the mirror, execute it again.docker imagesCommand prompt permission is insufficient:Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.29/ images/json: dial unix /var/run/docker.sock: connect: permission denied. Execute at this timesuThe command wants permission to find all passwords are wrong.
    • My ..DockerfileFile content:
    FROM jenkins:alpine
     USER root
     RUN curl -O https://get.docker.com/builds/Linux/x86_64/docker-latest.tgz \
     && tar zxvf docker-latest.tgz \
     && cp docker/docker /usr/local/bin/ \
     && rm -rf docker docker-latest.tgz
     ARG DOCKER_GID=999
     USER jenkins:${DOCKER_GID}
    • My ..docker runCommand:
    docker run -p 49002:8080 --name jenkins_docker -d -v /Users/UserName/jenkins_docker:/var/jenkins_home -v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock jenkins_docker

    It is normal practice that docker images should be executed by the host. Not in docker container.

    Even if you do file mapping, the docker container cannot execute the host program.
    One of docker’s goals is to isolate each operating environment.
    If the program hosting the host can be run in the docker container, docker will have serious security problems.