Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the meaning of EXPOSE in dockerfile

Shulou Source: shulou.com Published: 2022-06-03 11:01:57 10月13日 Update

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!

Tags: File port service meaning content container runtime more article mirror interpretation configuration good practical creator just tail meaning where Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Redmi macOS Apple vpn