哈特中尉's Blog

不会写代码的司机不是好厨师!

centos7安装docker

1
2
3
4
5
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce
systemctl start docker
systemctl enable docker

docker volumes 位置

1
var/lib/docker/volumes

拉去镜像

1
2
3
docker pull jenkinsci/blueocean

docker pull jenkins/jenkins

启动jenkins镜像

1
docker run -u root --rm -d -p 8080:8080 -p 50000:50000  -v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/mv:/usr/bin/mv -v /usr/java/jdk1.8.0_212-amd64:/usr/java/jdk1.8.0_212-amd64  -v /usr/maven/maven-3.6.1:/usr/maven/maven-3.6.1  -v /var/jenkins_home:/var/jenkins_home  jenkinsci/blueocean
启动springboot项目
1
docker run -v /etc/localtime:/etc/localtime:ro -p 8080:8080 -e "SPRING_PROFILES_ACTIVE=test" -d --add-host mysql.dxrj.cn:192.168.1.194 --name mall --restart=always --net=host mall
docker迁移存储文件位置
  • 1.新建目标文件夹
    1
    mkdir -p /mnt/vdb1/docker/lib
  • 2.迁移原来的文件到目标文件夹
    1
    rsync -avz /var/lib/docker /mnt/vdb1/docker/lib
  • 3.编辑配置文件(不存在就新建)
    1
    2
    mkdir -p /etc/systemd/system/docker.service.d/
    vi /etc/systemd/system/docker.service.d/devicemapper.conf
    文件内容如下
    1
    2
    3
    [Service]
    ExecStart=
    ExecStart=/usr/bin/dockerd --graph=/mnt/vdb1/docker/lib/docker
  • 4.重新加载 docker
    1
    2
    3
    systemctl daemon-reload
    systemctl restart docker
    systemctl enable docker