Let's try to run the second Tomcat container without stopping the first one:
$ docker run -d -p 8080:8080 tomcat0835c95538aeca79e0305b5f19a5f96cb00c5d1c50bed87584cfca8ec790f241docker: Error response from daemon: driver failed programming external connectivity on endpoint distracted_heyrovsky (1b1cee9896ed99b9b804e4c944a3d9544adf72f1ef3f9c9f37bc985e9c30f452): Bind for 0.0.0.0:8080 failed: port is already allocated.
This error may be common. In such cases, we have to either take care of the uniqueness of the ports on our own or let Docker assign the ports automatically using one of the following versions of the publish command:
- -p <container_port>: publish the container port to the unused host port
- -P (--publish-all ...