Docker容器修改端口映射

  • 先停容器和docker服务
docker stop [容器id]
systemctl stop docker
  • 查询容器完整CONTAINER ID
docker inspect【CONTAINER ID】| grep Id
  • 修改容器配置文件 hostconfig.json 、config.v2.json
cd /var/lib/docker/containers/容器完整id
hostconfig.json参照已有映射修改、新增
    "PortBindings": {
        "10081/tcp": [{
                "HostIp": "",
                "HostPort": "10081"
            }
        ],
        "10081/udp": [{
                "HostIp": "",
                "HostPort": "10081"
            }
        ],
        "80/tcp": [{
                "HostIp": "",
                "HostPort": "8888"
            }
        ]
    },
config.v2.json



    "Config": {
        "Hostname": "a1b9dc131fa6",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "ExposedPorts": {
            "10081/tcp": {},
            "10081/udp": {},
            "443/tcp": {},
            "80/tcp": {}
        },
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": ["KUBOARD_ENDPOINT=http://192.168.137.2:8888", "KUBOARD_AGENT_SERVER_UDP_PORT=10081", "KUBOARD_AGENT_SERVER_TCP_PORT=10081", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "TZ=Asia/Shanghai", "KUBOARD_PROXY_COOKIE_TTL=36000", "KUBOARD_SERVER_LOGRUS_LEVEL=info", "KUBOARD_UI_DIR=/kuboard-ui", "KUBOARD_SERVER_PORT=80", "KUBOARD_TLS_CACHE=/data/autocert/.cache", "GIN_MODE=release", "KUBOARD_ETCD_ENDPOINTS=127.0.0.1:2379", "KUBOARD_LOGIN_TYPE=default", "KUBOARD_ROOT_USER=admin", "GITLAB_BASE_URL=https://gitlab.com", "LDAP_SKIP_SSL_VERIFY=true"],
        "Cmd": null,
        "Image": "eipwork/kuboard:v3",
        "Volumes": null,
        "WorkingDir": "",
        "Entrypoint": ["/entrypoint.sh"],
        "OnBuild": null,
        "Labels": {
            "maintainer": "shaohq@foxmail.com"
        }
    }
  • 重启
systemctl start docker
docker start [docker id]

 

posted @ 2021-06-20 13:02  故木  阅读(582)  评论(0编辑  收藏  举报