docker-修改容器掛載目錄


1、停止容器

systemctl stop docker.service

# 一定要停止容器,不然修改無效

#檢查容器是否已停止
docker ps

2、修改掛載點信息

"MountPoints": {
        "/etc/gitlab-runner": {
            "Source": "/opt/gitlab-runner/config",
            "Destination": "/etc/gitlab-runner",
            "RW": true,
            "Name": "",
            "Driver": "",
            "Type": "bind",
            "Propagation": "rprivate",
            "Spec": {
                "Type": "bind",
                "Source": "/opt/gitlab-runner/config",
                "Target": "/etc/gitlab-runner"
            },
            "SkipMountpointCreation": false
        },
        "/home/gitlab-runner": {
            "Source": "",
            "Destination": "/home/gitlab-runner",
            "RW": true,
            "Name": "27cbde18a296ee3f8cf2744d108e04fec26d0a75ecd1383d9deb4a5f802e26f7",
            "Driver": "local",
            "Type": "volume",
            "Spec": {},
            "SkipMountpointCreation": false
        },
        "/var/run/docker.sock": {
            "Source": "/var/run/docker.sock",
            "Destination": "/var/run/docker.sock",
            "RW": true,
            "Name": "",
            "Driver": "",
            "Type": "bind",
            "Propagation": "rprivate",
            "Spec": {
                "Type": "bind",
                "Source": "/var/run/docker.sock",
                "Target": "/var/run/docker.sock"
            },
            "SkipMountpointCreation": false
        },
        "/opt/maven": {
            "Source": "/opt/maven",
            "Destination": "/opt/maven",
            "RW": true,
            "Name": "",
            "Driver": "",
            "Type": "bind",
            "Propagation": "rprivate",
            "Spec": {
                "Type": "bind",
                "Source": "/opt/maven",
                "Target": "/opt/maven"
            },
            "SkipMountpointCreation": false
        }
    }

# 建議復制一個已有的掛載點,修改成添加的路徑,再追加到最后面,要注意在倒數第二個的結尾加“,”

3、重啟docker

systemctl start docker.service

# 確認容器是否啟動
docker ps

4、進去容器查看

docker exec -it 容器ID  /bin/bash


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM