jenkins sh构建运行shell脚本 docker: command not found

The simple way to run Docker-in-Docker for CI:https://tutorials.releaseworksacademy.com/learn/the-simple-way-to-run-docker-in-docker-for-ci

https://stackoverflow.com/questions/44850565/docker-not-found-when-building-docker-image-using-docker-jenkins-container-pipel

需要将宿主机的docker环境变量映射

-v /var/run/docker.sock:/var/run/docker.sock \

参数多了使用docker-compose

curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

docker-compose -v

cd /home
vi docker-compose.yml
version: '3'
services:
  jeknins:
    container_name:  'jenkins_pen'
    image:  jenkins/jenkins:lts
    restart: always
    user:  root
    ports:
    - "11005:8080"
    - "5000:5000"
    volumes:
    - /home/jenkins/data:/var/jenkins_home
    - /usr/bin/docker:/usr/bin/docker
    - /var/run/docker.sock:/var/run/docker.sock
//若docker-compose.yml  user 权限不够会有报错
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
touch: cannot touch ‘/var/jenkins_home/copy_reference_file.log’: Permission denied

https://www.cnblogs.com/Uni-Hoang/p/12901055.html

https://www.cnblogs.com/Uni-Hoang/p/12901055.html

docker-compose up -d   //执行docker-compose.yml配置文件

2.docker容器的内数据备份

//docker cp
docker cp  containerId:/var/jenkins_home  /home/jenkins/data

#1.从宿主机向容器中复制文件

https://blog.csdn.net/u010046887/article/details/90408622?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase

[root@localhost data]# sudo docker cp aa.txt ssh001:/data

把当前目录下的aa.txt复制到容器名称为【ssh001】的data目录下

//官方备份volumes
https://docs.docker.com/storage/volumes/#backup-restore-or-migrate-data-volumes

猜你喜欢

转载自www.cnblogs.com/little-ab/p/12974139.html