Ignacio Valdes · Dec 1, 2019

Add ports to Google Cloud docker container?

I want to add ports 9100 and 9101 in addition to 52773. I read on docker container documentation that this is not possible on a already ran image. Currently it starts the google cloud IRIS health container automatically without me able to specify the additional ports. How can I add ports to Google cloud IRIS Health container?

1 0 5 531
Log in or sign up to continue

Suppose, you should look at Google's documentation. Particularly, about Using Firewall Rules

On the Firewall rules page, you will find some predefined rules, for your IRIS instance, something like on the picture.

So, you can just use it as a template, and do the same for your custom port.

It is not a firewall issue. It is a docker issue. Apparently you cannot add a port to a docker container once it has already been run/initiated. It has to be done at the initiation step.  The initiation step is already done when the google cloud instance is created so you cannot go back and un-initiate it.  -- IV

That's for Docker. GCP, while it uses containers, has a setup where all container's ports could possibly be available, but firewall prevents all access except specified firewall allow rules.

Adding firewall access, as specified by @Dmitry Maslennikov should help.

Yeah, I forgot about docker. But it is possible to solve this as well. 

Connect to the instance with SSH in any way offered by Google.

cd /opt/ISC
sudo vi docker-compose.yml

So, you can now add more ports. Save it (:wq)))

sudo docker-compose up -d

Do not forget to configure firewall rules.

You can even add this line, and remove ports block at all, and get access to any future ports without a restart container.

network_mode: host

And so it is:

@intersystems-iris-community-edition-1-vm:~$ cd /opt/ISC
@intersystems-iris-community-edition-1-vm:/opt/ISC$ sudo vim docker-compose.yml
@intersystems-iris-community-edition-1-vm:/opt/ISC$ sudo docker-compose up -d
Recreating try-iris ... done
@intersystems-iris-community-edition-1-vm:/opt/ISC$ sudo docker ps -a
CONTAINER ID        IMAGE                                            COMMAND             CREATED              STATUS                                 PORTS                      
db93ab338e46        intersystems/iris-community:2019.4.0.379.0-gcp   "/iris-main"        About a minute ago   Up About a minute (health: starting)>9100-910
1/tcp,>51773/tcp,>52773/tcp   try-iris