安装docker

卸载旧版本

  1. sudo yum remove docker \
  2. docker-client \
  3. docker-client-latest \
  4. docker-common \
  5. docker-latest \
  6. docker-latest-logrotate \
  7. docker-logrotate \
  8. docker-engine

设置仓库

  1. sudo yum install -y yum-utils
  2. sudo yum-config-manager \
  3. --add-repo \
  4. https://download.docker.com/linux/centos/docker-ce.repo

安装Docker

  1. sudo yum install docker-ce docker-ce-cli containerd.io

使用Docker

启动

  1. # 设置开机启动
  2. systemctl enable docker
  3. # 启动Docker
  4. systemctl start docker

启动一个Jenkins容器

  1. docker run -d --name jenkins -v /opt/jenkins_home:/var/jenkins_home --env JAVA_ARGS="-Xms1g -Xmx1g -Dhudson.util.ProcessTreeKiller.disable=true -Dorg.jenkinsci.plugins.gitclient.Git.timeOut=60 -Djava.awt.headless=true -Dhudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION=true -Dfile.encoding=UTF-8" -p 8888:8080 -p 50000:50000 jenkins/jenkins:centos7