1.停止docker
[[email protected] data]# systemctl stop docker
2.创建目录,拷贝数据
[[email protected] data]# mkdir -p /newdata/jenkins //要保证目录的属主和属组不变,设置新目录权限777是为了cp -a能正常拷贝属主和属组等全部信息 [[email protected] data]# chmod 777 /newdata/jenkins [[email protected] data]# cp -a /data/jenkins /newdata/jenkins [[email protected] data]# ll /newdata/ total 36 drwxr-xr-x 4 root root 4096 Feb 11 11:02 elasticsearch drwxrwxrwx 22 root root 4096 May 18 12:57 jenkins drwx------ 2 root root 16384 Mar 22 17:08 lost+found drwxr-xr-x 10 root root 4096 Mar 26 2018 zbox [[email protected] data]#
3.容器的配置文件路径:
修改 /var/lib/docker/containers/[hash_of_the_container]/config.v2.json
/var/lib/docker/containers/[hash_of_the_container]/hostconfig.json
其中的hashofthecontainer是docker镜像的hash值,可以通过docker ps或者docker inspect containername查看。(CONTAINER ID就可以看出来)
[[email protected] data]# vim /var/lib/docker/containers/fcaad17f146a1007893edbe751115f2ae63d79194b65fa087a789d14f83a161f/config.v2.json {"StreamConfig":{},"State":{"Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"RemovalInProgress":false,"Dead":false,"Pid":24349,"ExitCode":0,"Error":"","StartedAt":"2019-05-18T04:35:39.507700768Z","FinishedAt":"2019-05-18T04:12:26.528451231Z","Health":null},"ID":"fcaad17f146a1007893edbe751115f2ae63d79194b65fa087a789d14f83a161f","Created":"2018-12-28T01:08:39.536640015Z","Managed":false,"Path":"/sbin/tini","Args":["--","/usr/local/bin/jenkins.sh"],"Config":{"Hostname":"fcaad17f146a","Domainname":"","User":"jenkins","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":{"50000/tcp":{},"8080/tcp":{}},"Tty":true,"OpenStdin":true,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","LANG=C.UTF-8","JAVA_HOME=/docker-java-home","JAVA_VERSION=8u181","JAVA_DEBIAN_VERSION=8u181-b13-2~deb9u1","CA_CERTIFICATES_JAVA_VERSION=20170531+nmu1","JENKINS_HOME=/var/jenkins_home","JENKINS_SLAVE_AGENT_PORT=50000","JENKINS_VERSION=2.156","JENKINS_UC=https://updates.jenkins.io","JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental","JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals","COPY_REFERENCE_FILE_LOG=/var/jenkins_home/copy_reference_file.log"],"Cmd":null,"ArgsEscaped":true,"Image":"docker.io/jenkins/jenkins","Volumes":{"/var/jenkins_home":{}},"WorkingDir":"","Entrypoint":["/sbin/tini","--","/usr/local/bin/jenkins.sh"],"OnBuild":null,"Labels":{}},"Image":"sha256:b98274c3cead6d68a875674e5c3d9b7914dd2f11387bb9a5f45bcd85dc8ed515","NetworkSettings":{"Bridge":"","SandboxID":"82d8475fa007d2ec3feec9d00edc654a60e8d816fde8b859699932fbdf5ec262","HairpinMode":false,"LinkLocalIPv6Address":"","LinkLocalIPv6PrefixLen":0,"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"NetworkID":"8c416d9ba2eb99b7a7f5a3a7b17db6392d764ecc7a45f8535bab0c6330854bd9","EndpointID":"30a8019f6a70f9e3b5cd0d191099070e2e52996f083784f1cfde51db675244b8","Gateway":"172.17.0.1","IPAddress":"172.17.0.7","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:11:00:07","IPAMOperational":false}},"Service":null,"Ports":{"50000/tcp":[{"HostIp":"0.0.0.0","HostPort":"50000"}],"8080/tcp":[{"HostIp":"0.0.0.0","HostPort":"8080"}]},"SandboxKey":"/var/run/docker/netns/82d8475fa007","SecondaryIPAddresses":null,"SecondaryIPv6Addresses":null,"IsAnonymousEndpoint":false,"HasSwarmEndpoint":false},"LogPath":"","Name":"/jk01","Driver":"overlay2","MountLabel":"","ProcessLabel":"","RestartCount":0,"HasBeenStartedBefore":true,"HasBeenManuallyStopped":false,"MountPoints":{"/var/jenkins_home":{"Source":"/newdata/jenkins","Destination":"/var/jenkins_home","RW":true,"Name":"","Driver":"","Type":"bind","Propagation":"rprivate","Spec":{"Type":"bind","Source":"/newdata/jenkins","Target":"/var/jenkins_home"}}},"SecretReferences":null,"AppArmorProfile":"","HostnamePath":"/var/lib/docker/containers/fcaad17f146a1007893edbe751115f2ae63d79194b65fa087a789d14f83a161f/hostname","HostsPath":"/var/lib/docker/containers/fcaad17f146a1007893edbe751115f2ae63d79194b65fa087a789d14f83a161f/hosts","ShmPath":"/var/lib/docker/containers/fcaad17f146a1007893edbe751115f2ae63d79194b65fa087a789d14f83a161f/shm","ResolvConfPath":"/var/lib/docker/containers/fcaad17f146a1007893edbe751115f2ae63d79194b65fa087a789d14f83a161f/resolv.conf","SeccompProfile":"","NoNewPrivileges":false}
[[email protected] data]# cat /var/lib/docker/containers/fcaad17f146a1007893edbe751115f2ae63d79194b65fa087a789d14f83a161f/hostconfig.json {"Binds":["/newdata/jenkins:/var/jenkins_home"],"ContainerIDFile":"","LogConfig":{"Type":"journald","Config":{}},"NetworkMode":"default","PortBindings":{"50000/tcp":[{"HostIp":"","HostPort":"50000"}],"8080/tcp":[{"HostIp":"","HostPort":"8080"}]},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"CapAdd":null,"CapDrop":null,"Dns":[],"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"","Cgroup":"","Links":[],"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"docker-runc","ConsoleSize":[0,0],"Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":null,"BlkioDeviceReadBps":null,"BlkioDeviceWriteBps":null,"BlkioDeviceReadIOps":null,"BlkioDeviceWriteIOps":null,"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DiskQuota":0,"KernelMemory":0,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":-1,"OomKillDisable":false,"PidsLimit":0,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0} [[email protected] data]#
4.重启docker
[[email protected] data]# systemctl start docker [[email protected] data]# docker start jenkins
原文地址:https://www.cnblogs.com/linyouyi/p/10885450.html
时间: 2024-10-03 01:30:13