As we all know, if the outside to communicate with the Docker container, in addition to the link must be a port mapping, the following first describes the use of the Dockerfile expose, and then do a multi-port random mapping example bar.
The format is:
EXPOSE PORT
Here's my dockerfile.
# Tomcat
# Version 0.0.1
# get_image from
192.168.0.216:5000/centos
# maintainer_info
Maintainer Hongxue hongxue@showjoy.com
Run yum-y install vim
run yum-y install net-tools
RUN yum-y Install Openssh-ser Ver
RUN yum-y install wget Curl
# PORT
EXPOSE 8080
EXPOSE
EXPOSE 8009 EXPOSE 8005 EXPOSE 8443
I defined Tomcat's four ports and SSH 22 ports in Dockerfile and built the profile as an image file with the image named Port_list
Docker build-t port_list.
Docker Images | grep port_list
Run the images after the build is successful, and note that you must add-p when the container is running
Docker run-d-it-p--name Port_list_container port_list
Ok,container already running, mapping ports (22,8005,8009,8443,8080) to native (32775,32776,32777,32773,32774)