With Container Run
When we run the container using docker container run --publish 80:80 --name <container-name> nginx, it actually interpret by docker container run --publish 80:80 --name <container-name> -d nginx:latest nginx -T.
This command do the following steps:
- Look for
Nginximage in local cache, if not found get it fromDockerregistry. - If we specify the image version, it will be downloaded
- If we do not specify the image, it will download the latest version
- Create a container out of the image
- Give a virtual IP on a private network inside the
Docker Engine - Open port
80in host machine and forward all traffic of80to docker container port80 - Start executing container start up command
So while run the container using the specified command, we can change the port mapping and also the image version.