i know when we give the -p option with docker run command like docker run -p 8080:8080 dockerimage , it will run on docker port 8080... but i want to write the docker run command with just container ID without -p option... like docker run imagename (without specifying port name)
if i write EXPOSE 8080/tcp in dockerFile, then when i run docker, it just opens port Exposed in dockerfile, but i want to make the docker run on specific port (not port 80). May be docker-compose will help me achieve it?
Please guide.
There is certainly no way to forward ports with Dockerfile but it is possible with docker-compose
:
version: "3"
services:
myapp:
image: hello-world
ports:
- 8080:80
See the compose file reference
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.