Tag: port

Process Listening on a Particular Port in Linux

Process Listening on a Particular Port in Linux

These commands might not workable in some Unix like systems.

Using netstat

netstat -ltnp
netstat -peanut

lsof

lsof -i :80

fuser

fuser 80/tcp

ss


ss -nlp
``

## References

[3 Ways to Find Out Which Process Listening on a Particular Port](https://www.tecmint.com/find-out-which-process-listening-on-a-particular-port/)

TODO: Change docker container mapping port

Change docker container mapping port

To change the running container mapping port with or without recreating container.

By recreating container

Stop and commit running container, then run new container using new image.

This requires changing image name and knowing the docker run command parameters.

docker stop test01
docker commit test01 test02
docker run -p 8080:8080 -td test02

Modify configuration file

Stop the container and docker service, then change the docker container configuration file hostconfig.json. After that, start docker service and container.

This requires updating docker run command document.

  1. Stop docker.
docker stop test01
systemctl stop docker
  1. Edit hostconfig.json file
vi /var/lib/docker/containers/[hash_of_the_container]/hostconfig.json

or following file when using snap

/var/snap/docker/common/var-lib-docker/containers/[hash_of_the_container]/hostconfig.json
  1. Start docker
systemctl start docker
docker start test01