How to start your Docker container using a different port
When you start Solace PubSub+ using Docker, it exits with an error message like the following:
docker: Error response from daemon: driver failed programming external connectivity on endpoint solacePSPlusStandard … (really long numbers here): Error starting userland proxy: listen tcp 0.0.0.0:8080: bind: address already in use.
This error message means that another program (process) is listening on the port 8080. Since only one process can listen on a given port, Docker is thus unable to start your container.
- Solace PubSub+ in Docker container
If you know what process is using that port, you may be able to stop that process so that PubSub+ can use that port.
In this article, we will discuss how to start your Docker container using a different port.
Follow the steps below:
- Find a free TCP port that you can use.
- Delete the existing container using the following command:
docker rm solacePSPlusStandard
Why delete the existing container?
When Docker creates a container from the packages it downloads or from a dockerfile, it assigns the ports to it. To change the ports, you need to delete the existing container first, then re-create it.
- Restart with a different host port number, for example:
docker run -d -p 8083:8080 -p 55555:55555 -p:80:80 --shm-size=2g --env username_admin_globalaccesslevel=admin --env username_admin_password=admin --name=solacePSPlusStandard solace/solace-pubsub-standard
In this example, 8080 is the port in use and 8083 is a free port.
Note that Docker’s -p parameter requires two numbers separated by a colon (e.g.
-p 8080:8080). The number on the left is the port on the host computer. The number on the right is the port on the process running in Docker. Docker maps the port on the host to the port on the process running in Docker.
So, to use port
8083 on your host computer mapped to port
8080 in Solace PubSub+ running in Docker, you should write Docker’s -p parameter for port 80 as
You can now use the free port to test PubSub+ with Docker without the “address already in use” error message.