Jenkins使用Docker-compose

pkln4tw6  于 11个月前  发布在  Docker
关注(0)|答案(1)|浏览(134)

通过Linux命令行运行docker-compose start命令,项目已正确构建并启动,但在我构建的管道中,当运行docker-compose up时,发生以下错误
错误代码:For php Cannot start service php:driver failed programming external connectivity on endpoint bcc1dda8781b_ngweb-php-1(58165db54561cd3ea0a34d3af1721084966d02b48a242321409840e25f109b9b):Error starting userland proxy:listen tcp4 0.0.0.0:443:bind:address already in
有人知道是什么吗?
下面是docker-compose和Jenkinsfile文件。
docker-compose.yaml

version: "3.1"
services:
  ngwebsite:
    image: jceleste/ngweb:115
    networks:
      - mysql_server
    ports:
      - 8282:80
    depends_on:
      - db
    links:
      - db
  db:
    image: mysql:5.7
    networks:
      - mysql_server
    command: --innodb_use_native_aio=0
    restart: always
    volumes:
      - db_data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=*******
      - MYSQL_DATABASE=ngweb
    ports:
      - 3302:3306
volumes:
  db_data:
networks:
  mysql_server:

字符串
Jenkinsfile

pipeline {
    agent any
    
    environment { 
        registry = "jceleste/ngweb" 
        dockerImage = '' 
        tag_version = "${env.BUILD_ID}"     
        tag_generic  =  '{{TAG}}'
    }

    stages {
         stage ('Build Docker Image'){
             steps{
                 script {
                     dockerapp = docker.build("jceleste/ngweb:${env.BUILD_ID}", '-f ./Dockerfile ./ ')
                     
                }
             } 
        }   
        
        stage ('Push Docker Image'){
            steps {
                script {
                    docker.withRegistry('https://registry.hub.docker.com/','dockerhub'){
                     dockerapp.push("${env.BUILD_ID}")
                    }
                }
            }
        }
        
        
        
        stage ('Deploy Docker Image'){
          
            steps{
                script {
                    sh 'sed -i "s/{{TAG}}/$tag_version/g" /home/ngweb-compose/docker-compose.yaml'
                    sh 'docker-compose start'
                    
                    sh 'sed -i "s/$tag_version/$tag_generic/g" /home/ngweb-compose/docker-compose.yaml'
                }
                
            }
           
        }
    }

}


管道正确构建并启动Docker镜像

u91tlkcl

u91tlkcl1#

正如上面的评论中所指出的,在主机上使用端口443检查您现有的服务或应用程序。由于您使用的是Linux,使用sudo lsof -i :443检查使用端口443的特定进程。如果可以,请停止该进程以释放端口或更改撰写文件的端口。我假设您的Web服务器在Nginx上运行。
所以,我会将我的docker-compose.yaml更改为

version: "3.1"
services:
  ngwebsite:
    image: jceleste/ngweb:115
    networks:
      - mysql_server
    ports:
      - "8282:443"
    depends_on:
      - db
    links:
      - db

  db:
    image: mysql:5.7
    networks:
      - mysql_server
    command: --innodb_use_native_aio=0
    restart: always
    volumes:
      - db_data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=*******
      - MYSQL_DATABASE=ngweb
    ports:
      - "3302:3306"

volumes:
  db_data:

networks:
  mysql_server:

字符串
您可以运行docker-compose up -d来启动您的服务与更新的端口Map.
然而,我很好奇为什么你的图像被标记为<115>,但在Jenkinsfile中却不同。我想你会匹配它们。

相关问题