CI/CD project failure problem in jenkins container

Problem: Failed to create a vue project image on CI/CD in the docker container of jenkins

1. Docker permission problem

permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/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&shmsize=0&t=[镜像仓库地址]&target=&ulimits=null&version=1": dial unix /var/run/docker.sock: connect: permission denied
make: *** [makefile:6: docker_build] Error 1

1.1 Reason: Inside the jenkins container: docker.sock permission

1.2 Problem solution

cd /var/run        //进入dock儿.sock文件夹下
ls -al         //查看文件的权限

The file permissions are as follows:
srw-rw---- 1 root 994 0 Jun 30 06:51 docker.sock
for permission modification

chown root:root docker.sock
chmod o+rw docker.sock

The final permission is successfully modified to: srw-rw-rw- 1 root root 0 Jun 30 06:51 docker.sock

2、npm: not found

2.1 Cause of the problem

The project is a front-end vue, which depends on nodejs and npm. You need to install npm and nodejs for the container

2.2 Problem solution

Environment required for installation

apt-get update
apt-get install -y npm 

3、make: not found

3.1 Cause of the problem

Use the make statement to execute, you need to install make for the container

3.2 Problem solution

apt-get install make

4. Use the docker command prompt in the jenkins container: /var/run/docker.sock: connect: permission denied

4.1 Cause of the problem

Docker cannot be used to package image files in the jenkins container

4.2 Problem solution

docker run \
-d \
--name jenkinsnew \
-p 9999:8080 \
// -p 8888:8888 \
// -p 50000:50000 \                   //-p	指定端口映射,格式:<主机(宿主)端口>:<容器端口>
--privileged=true \                                   //容器可以访问主机上的设备或系统功能
-v /usr/local/src/jdk/jdk1.8:/usr/local/src/jdk/jdk1.8 \
-v /opt/apache-maven-3.5.0:/opt/apache-maven-3.5.0 \
-v /home/jenkins_home:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \    
	 //-v表示使用数据卷。<host目录>:<容器目录>
 	//Docker容器内的目录挂载到主机对应的目录上,使该两个目录下的数据保持同步
-v /usr/bin/docker:/usr/bin/docker \
jenkins/jenkins:lts
···




Guess you like

Origin blog.csdn.net/shengmeshi/article/details/132234223