SoFunction
Updated on 2025-03-10

docker: Add port and get dockerfile

Get dockerfile from docker image

docker history --format {{.CreatedBy}} --no-trunc=true $DockerImage
|sed “s//bin/sh\ -c\ #(nop)\ //g”|sed “s//bin/sh\ -c/RUN/g” |
tac

Note: The docker file does not map the directory and ports, and does not execute the scripts and server services that docker boot and start.

docker multi-port mapping

Docker Multi-Port

docker run -it -d --name container-name -p p1:p1 -p p2:p2 new-image-name -ip xxxxx —restart=always

Method 1:

Add ports at runtime

/var/lib/docker/containers/{container_id}/

Method 2:
Submit a running container as a mirror:

docker commit containerid now/live

Run the image and add the port:

docker run -d -p 8000:80 now/live /bin/bash

Obtain container IP:

docker inspect container_name | grep IPAddressiptableForwarding portiptables -t
nat -A DOCKER -p tcp --dport 8001 -j DNAT --to-destination
172.17.0.19:8000

Note: Mac may not enter the screen

Passing files to docker

sudo docker save -o /home/ubuntu_14804.tar 93123213127ccc

This is the article about adding ports to docker and obtaining dockerfiles. For more related docker to add ports and obtain dockerfiles, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!