Docker Community Forums

Share and learn in the Docker community.

Remove saved ports from docker images? New Container has old ports and intercepts working old container ports


(Lp5pr) #1

had original ubuntu image
created container “masternode-container-1234” with port 1234 from ubuntu image
saved container to image "masternode-image-1"
want to create new container with different port
docker run -itd -p 2345 --restart=always --name “masternode-container-2345” masternodes-image-1 bash
but old ports are again exposed

docker ps
masternode-container-2345 with open ports 1234/tcp, 2345/tcp

should be only 2345/tcp
cannot get rid of old port 1234

masternode-container-1234 is running with port 1234

so it is a total mess, new container intercepts 1234 port and makes masternode-container-1234 usless

what to do?
how to make new container with new ports without old ports?


(Sam) #2

i don’t think you can remove definitions… only add


(Lp5pr) #3

how do I edit ?
“ExposedPorts”: {
“1234/tcp”: {}
},

                          latest              747cb2d60bbe        4 months ago        122 MB

masternode@Ubuntu-1604-xenial-64-minimal:~$ docker inspect masternodes-image-1
[
{
“Id”: “sha256:0f9c050cb760f6420df2655ccf8721758336b227b8e20797c16375bc1ca39f4d”,
“RepoTags”: [
“masternodes-image-1:latest”
],
“RepoDigests”: [],
“Parent”: “sha256:747cb2d60bbecbda48aff14a8be5c8b913ca69318a6067e57c697f8a78dda06e”,
“Comment”: “”,
“Created”: “2018-02-07T16:06:25.439697485Z”,
“Container”: “e4658ba3ec876f061063041df81cd47949bd114872562a5073acb96bb69fef42”,
“ContainerConfig”: {
“Hostname”: “e4658ba3ec87”,
“Domainname”: “”,
“User”: “”,
“AttachStdin”: false,
“AttachStdout”: false,
“AttachStderr”: false,
“ExposedPorts”: {
“1234/tcp”: {}
},
“Tty”: true,
“OpenStdin”: true,
“StdinOnce”: false,
“Env”: [
“PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
],
“Cmd”: [
“bash”
],
“Image”: “ubuntu”,
“Volumes”: null,
“WorkingDir”: “”,
“Entrypoint”: null,
“OnBuild”: null,
“Labels”: {}
},
“DockerVersion”: “1.12.6”,
“Author”: “”,
“Config”: {
“Hostname”: “”,
“Domainname”: “”,
“User”: “”,
“AttachStdin”: false,
“AttachStdout”: false,
“AttachStderr”: false,
“ExposedPorts”: {
“9999/tcp”: {}
},
“Tty”: false,
“OpenStdin”: false,
“StdinOnce”: false,
“Env”: [
“PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
],
“Cmd”: [
“bash”
],
“Image”: “”,
“Volumes”: null,
“WorkingDir”: “”,
“Entrypoint”: null,
“OnBuild”: null,
“Labels”: {}
},
“Architecture”: “amd64”,
“Os”: “linux”,
“Size”: 6346084312,
“VirtualSize”: 6346084312,
“GraphDriver”: {
“Name”: “aufs”,
“Data”: null
},
“RootFS”: {
“Type”: “layers”,
“Layers”: [
“sha256:0f5ff0cf6a1c53f94b15f03536c490040f233bc455f1232f54cc8eb344a3a368”,
“sha256:cd181336f1422e8169eaa7be4abe0d06c71340e515e7e44baba2f842b54f67e2”,
“sha256:b97229212d30d1b0bbb04aaeac57646791f2073be372474c9fe02cd7dfe65c98”,
“sha256:4589f96366e69fc4ed9c118f43bd7ccd033d710eba8c1ba3b6d758b2cba668a7”,
“sha256:49907af65b0a659b157be1dc099c3f71c42dfe2e599998e3157ebcf1b12a5652”,
“sha256:de11a9b8d5d3dcaafdfabf5ee45341063d070b7767bec57fcfbfbb2a1c81d031”
]
}
}
]
masternode@Ubuntu-1604-xenial-64-minimal:~$


(Sam) #4

edit the dockerfile and change the EXPOSE keyword… then rebuild the image…
thats the only way I know


(Lp5pr) #5

there is no dockerfile
how to find it for particular image?


(Sam) #6

who created the image?