修改docker+jenkins挂载目录

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

修改docker+jenkins挂载目录的相关文章

docker查看挂载目录Volume

使用docker inspect命令查看container的volume信息,按照书本上面敲,发现一直报错: 使用命令如下: sudo docker inspect --format "{{.Volumes}}" 676b04bec7c5 错误信息为 Template parsing error: template: :1:2: executing "" at <.Volumes>: map has no entry for key "Volu

修改 docker image 安装目录 (解决加载大image时报错:&quot;no space left on device&quot; )

问题原因:出现此问题一般是 docker 根目录空间不足导致 解决方法:重新指定docker image 安装目录,当然确保你新指定的目录有足够的空间. 方法步骤: ##查看 docker 的根目录 [[email protected] k8s]# docker info | grep -i "docker root dir" WARNING: You're not using the default seccomp profile Docker Root Dir: /var/lib/

docker给已经启动容器添加挂载目录

docker添加挂载目录:先在docker容器里创建目录/import 1.关闭docker:/etc/init.d/docker stop2.sudo su切换到root身份,cd /var/lib/docker/containers/容器id/,进入对应容器目录3.vi hostconfig.json,修改如下,将容器目录/import绑定到主机/data目录: "Binds": ["/data:/import"], 4.vi config.v2.json,修改

docker 挂载目录

原文出处:https://www.linuxidc.com/Linux/2015-09/123519.htm  ,感谢原博主分享. Docker容器启动的时候,如果要挂载宿主机的一个目录,可以用-v参数指定. 譬如我要启动一个CentOS容器,宿主机的/test目录挂载到容器的/soft目录,可通过以下方式指定: # docker run -it -v /test:/soft centos /bin/bash 这样在容器启动后,容器内会自动创建/soft的目录.通过这种方式,我们可以明确一点,即

linux修改挂载目录

linux修改挂载目录 修改扩展磁盘默认的挂载点/home到/data [[email protected] ~]# df -h 文件系统       容量  已用  可用 已用%% 挂载点 /dev/mapper/VolGroup-lv_root 50G  3.3G   44G   7% / tmpfs                 7.7G     0  7.7G   0% /dev/shm /dev/sda2             485M   36M  424M   8% /boot

centos:解决docker容器内挂载目录无权限 ls: cannot open directory .: Permission denied

docker运行一个容器后,将主机中当前目录下的文件夹挂载到容器的文件夹后 进入到docker容器内对应的挂载目录中,运行命令ls后提示: ls: cannot open directory .: Permission denied 解决: 在docker run一个容器时,加上 --privileged=true 给容器加特权即可. 原文地址:https://www.cnblogs.com/UniqueColor/p/9318815.html

Centos7 &amp; Docker &amp; Jenkins &amp; ASP.NET Core 2.0 自动化发布和部署

写在前面 Docker一直很火热,一直想把原本的Jenkins自动部署工具搬到Docker上面,无奈今年一直忙于各种事情,迟迟未实施这个事情,正好迎来了dotnet core 2.0 的正式发布,升级项目的同时,顺便直接将Jenkins搬到Docker上.为什么要写这篇文章呢?因为找过相关的资料,大多数文章都是基于Ubuntu 安装.net core 又或者 GitLab 进行持续集成 自动部署等等等,并未有人尝试过Centos7.3 上部署 Jenkins 并且 构建 ASP.NET CORE

centos7+docker+Jenkins+svn搭建自动化部署平台

centos7+docker+Jenkins+svn搭建自动化部署平台 1. centos7 参考链接:http://www.macrozheng.com/#/reference/linux_install tips 公司服务器配置(1T机械+256固态+i7的u) 需要我们把系统,环境(java,mysql,redis,docker等)装到固态上(速度快),我们的代码放到机械上.分区情况如下图 2. centos7中安装docker1.31.1 自行百度,此处无坑 3. centos7安装配置

四个修改Docker默认存储位置的方法

方法一.软链接 默认情况下Docker的存放位置为:/var/lib/docker 可以通过下面命令查看具体位置: sudo docker info | grep "Docker Root Dir" 解决这个问题,最直接的方法当然是挂载分区到这个目录,但是我的数据盘还有其他东西,这肯定不好管理,所以采用修改镜像和容器的存放路径的方式达到目的. 这个方法里将通过软连接来实现. 首先停掉Docker服务: systemctl restart docker或者service docker s