Expose additional port in running docker container



Sometimes you need to expose additional port on running container without rebuilding it from image.

Here are steps which worked for me:

  1. stop the container
  2. stop docker service (can skip - restart later is enough)
  3. change the files
/var/lib/docker/containers/<conainerID>
config.v2.json
"Config": {
....
"ExposedPorts": {
"80/tcp": {},
"8888/tcp": {}
},
....
},
"NetworkSettings": {
....
"Ports": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "80"
}
],
hostconfig.json
"PortBindings": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "80"
}
],
"8888/tcp": [
{
"HostIp": "",
"HostPort": "8888"
}
]
}

restart your docker engine (to flush/clear config caches)

systemctl restart docker	
  1. start the container

Recent Posts

Few basic js snippets

Expose additional port in running docker container

Electron window shenanigans

List all subfolders in current location and calculate their sizes

← Back to all posts