Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the meaning of EXPOSE in dockerfile

2025-03-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about what EXPOSE means in dockerfile. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Use the local dockerfile to build the image. The content of dockerfile: execute after the construction of EXPOSE3000 is completed: dockerrun-p3000:3000-dnginx:v0 enters localhost:3000 in the browser and cannot access the service.

The explanation of EXPOSE

The EXPOSE directive declares that the runtime container provides a service port, which is just a declaration that the service on this port will not be opened by the application at runtime because of this declaration.

I've figured it out. The EXPOSE you understand doesn't mean the same as the explanation given by the authority.

The default port provided by nginx runtime is 80, even if you declare 3000 here, it will not change the default port 80.

This EXPOSE wool is useless. It is usually written by the creator of the mirror. If it is miswritten, it will mislead the user and take the person to the pit.

Therefore, when declaring EXPOSE, be sure to find out the default service port of the current container.

The meaning of EXPOSE in dockerfile

How to check the default port of nginx? Look it up in the nginx.config file.

First go to the nginx container: dockerexec-it412a3bcbac7f/bin/bash

Then query the nginx configuration file: whereisnginx.config

Go to the directory where the configuration file cd/etc/nginx is located and view the nginx.config file

Http {

Include/etc/nginx/mime.types

Default_typeapplication/octet-stream

Log_formatmain'$remote_addr-$remote_user [$time_local] "$request"'

'$status$body_bytes_sent "$http_referer''

'"$http_user_agent"$http_x_forwarded_for"'

Access_log/var/log/nginx/access.logmain

Sendfileon

# tcp_nopushon

Keepalive_timeout65

# gzipon

Include/etc/nginx/conf.d/*.conf

}

No port found, but include/etc/nginx/conf.d/*.conf exists at the end of the file

Look directly at this file.

Thank you for reading! This is the end of the article on "what is the meaning of EXPOSE in dockerfile". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report