How do you specify port mapping in Docker?
In Docker, you can use the -p parameter to specify port mapping. This parameter format is host port:container port, where the host port is the port you want to map the container port to, and the container port is the port of the service running inside the container.
Here is an example command for specifying port mapping:
docker run -p 8080:80 ubuntu:latest
The command above will run an Ubuntu image in a container and map port 80 in the container to port 8080 on the host.
If multiple port mappings need to be specified, the -p parameter can be used multiple times as shown below:
docker run -p 8080:80 -p 4444:443 ubuntu:latest
The above command maps port 80 in the container to port 8080 on the host, and maps port 443 in the container to port 4444 on the host.
Please note that the specified host port must be available and the service in the container must be listening on the specified container port.