Scale our Docker Containers on Multiple Ports
Want to be able to scale you application so it has mutiple instances of the same app? We can do this by running the app on a particular port.
Create 3 Docker containers from our Image
This will assign each instance a random and unused port from Docker named instance1, instance2, instance3
docker run -d -P --name instance1 mattwen/discord-draw:latest
docker run -d -P --name instance2 mattwen/discord-draw:latest
docker run -d -P --name instance3 mattwen/discord-draw:latest
Review the port numbers
docker container list -a
Docker created the app on ports 32768-32770 and directs to internal port 8080 (the port that the app is running on)
Inside Google Cloud Dashboard > Hamburger(Top Left corner) > VPC Network > Firewall Rules Create a Google Cloud VPN Exception for the new ports:
Add a name and the following information:
Visit the public ip address of your Compute Engine VM and verify it’s working!
Each port resolution now has it’s own unique app running inside of it!
Written on April 6, 2018