Dockerfile Multi-port mapping expose

Source: Internet
Author: User
Tags tomcat docker run

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.