Note: To start a container in detached mode, you use -d=true or just -d option. Detached mode, shown by the option –detach or -d , means that a Docker container runs in the background of your terminal.
sed -i 's#https://updates.jenkins.io/download#https://mirrors.tuna.tsinghua.edu.cn/jenkins#g' default.json sed -i 's#http://www.google.com#https://www.baidu.com#g' default.json
3. Other
Nginx config
If you want to route to Jenkins using Nginx, you can refer to the following Nginx configuration:
stage('Deploy') { agent any steps { // Unstash the build artifacts unstash 'blog-public' unstash 'nginx-config'
// Create a directory to store the build artifacts temporarily sh "rm -rf /jenkins_deploy/blog" sh "mkdir -p /jenkins_deploy/blog" sh "cp -r public /jenkins_deploy/blog" sh "cp default.conf /jenkins_deploy/blog"
// Deploy using Docker on the host machine sh ''' # Stop and remove existing container if it exists docker stop blog-nginx || true docker rm blog-nginx || true # Start a new container with the updated content docker run -d --name blog-nginx \ -p 4000:80 \ -v /root/jenkins/jenkins_deploy/blog/public:/usr/share/nginx/html \ -v /root/jenkins/jenkins_deploy/blog/default.conf:/etc/nginx/conf.d/default.conf:ro \ --restart unless-stopped \ nginx:alpine ''' } } } }