Refer to the exhibit.
A process running on the host wants to access the service running inside this Docker container. Which port or ports are used to make a connection?
Refer to the exhibit.
A process running on the host wants to access the service running inside this Docker container. Which port or ports are used to make a connection?
The correct port that a process running on the host uses to access the service running inside the Docker container is port 3000. The command 'docker run -p 3000:5000' maps port 3000 on the host to port 5000 in the container. This means that connections to port 3000 on the host are forwarded to port 5000 in the Docker container. Therefore, the process on the host will use port 3000 to make the connection, allowing it to access the service running inside the container on port 5000.
https://docs.docker.com/desktop/networking/ Port Mapping When you run a container with the -p argument, for example: docker run -p 80:80 -d nginx Docker Desktop makes whatever is running on port 80 in the container (in this case, nginx) available on port 80 of localhost. In this example, the host and container ports are the same. If, for example, you already have something running on port 80 of your host machine, you can connect the container to a different port: docker run -p 8000:80 -d nginx Now, connections to localhost:8000 are sent to port 80 in the container. The syntax for -p is HOST_PORT:CLIENT_PORT. B is correct
" -p 8080:80 would expose port 80 from inside the container to be accessible from the host's IP on port 8080 outside the container." Therefore in this scenario it is 3000
It should be D as stated by sds85. Documentation: https://docs.docker.com/config/containers/container-networking/#:~:text=Published%20ports&text=To%20make%20a%20port%20available,host%20to%20the%20outside%20world. Based on this, -p 3000:5000 means mapping container port 5000 to host port 3000. As the host want to access the container's service (which is published on port 5000), the host has to access container port 5000.
Agree.
it is asking which port is used by the process running on host. Host port is 3000 which is mapped to 5000 port on Docker . So answer is B , port 3000 on host
3000 would be internal container port 5000 would be external port that clients should access It's a tricky question, but put your brain to function. Which port the external client should access? Port 5000 So the answer is D
from documentation: -p 8080:80 Map TCP port 80 in the container to port 8080 on the Docker host.
yes, your statement above is right. However question says: "A process running on the host wants to access the service running inside this Docker container". So for me key words here 'on the host' and 'inside container'. Meaning that port 80 (or port 5000) is also accessible for application running on this host. If they ask about application outside who wants to use docker container service, then - yes, it has to be 8080 (or 3000). To me it's tricky question.
by other words, they don't ask here how to access docker container externally
Both is possible. It depends if you go for localhost and use the host port 3000 or with the container ip from the docker network and use port 5000 Only Cisco knows..
local or external services will connect to port 3000 and then it will be redirected to port 5000 running inside docker container
D is correct
Bad opcion
Answer is B (port 3000)... Go read the doc carefully whoever says D is the answer. It's not so difficult to understand the concept, just a simply mapping mechanism. '-p HOST_PORT:CONTAINER_PORT' i.e. -p 3000:12345 means in order to access docker from outside of host, you will use port 3000 on the host level, then it will connect into Docker service running inside of the host. Simply as that....
If the process were to be another container and it was deployed using the same docker virtual network, than yes the port would be 5000 , if the process was generic one would be 3000. I think is answer is B based on that.
A process running on the host wants to access the service running inside this Docker container. Which port or ports are used to make a connection? https://docs.docker.com/network/ "-p 3000:5000" - Map port 3000 on the Docker host to TCP port 5000 in the container. Another process can now reach the service running inside the container on: - localhost:3000 or - <IP address from the default docker network>:5000 ; port 5000 is not reachable via localhost Since this question is from an associate exam, there is no need to overthink. I would choose answer B. This question is only checking if you know the syntax. Using port 3000 on the host is easier and is how you would normally do it. Why would you map the host port from 3000 to 5000, if you are using it directly through the internal docker network ip adress with port 5000?
Answer should be -A (port 3000)
The Answer is D To access a service running inside a Docker container from the host, you need to know the port number that the service is listening on inside the container, and you also need to know the port number that is exposed on the host. These two port numbers do not have to be the same. For example, if a service inside the container is listening on port 8080, and you want to access it from the host, you can expose that port on the host by using the -p option when starting the container. For example: docker run -p 8080:8080 mycontainer This will expose port 8080 on the host, and any traffic sent to that port on the host will be forwarded to port 8080 inside the container.
In the docker run command, the -p flag is used to bind a host port to a container port. In this case, the command specifies that the host port 3000 should be bound to the container port 5000. This means that a process running on the host can access the service running inside the container by connecting to port 5000 on the host. Outbound connections between ports 3000 and 5000 are not mentioned in the command, so they are not relevant to the question.
Answer is B (port 3000)... Go read the doc carefully whoever says D is the answer. It's not so difficult to understand the concept, just a simply mapping mechanism. '-p HOST_PORT:CONTAINER_PORT' i.e. -p 3000:12345 means in order to access docker from outside of host, you will use port 3000 on the host level, then it will connect into Docker service running inside of the host. Simply as that....
Answer is D (port 5000) after reading the doc again... mod is there a way to update the content before it gets published?
Definitely D ... command syntax is -p host_ip:host_port:container_port/protocol