Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Compute Engine Container Webapp no port

nc2
Silver 1
Silver 1

Hello all, I made an instance template that loads a docker container in the configuration:

us-docker.pkg.dev/cloudrun/container/hello

I then made a managed instance group. I enabled NAT so that it could pull what it needed to launch the container and it is up and running. I got it up and running, but it keeps failing a health check. That is because HTTPS is not running for the container... 

nc2_1-1725302236261.png

There are no ports, and I don't know how to get a port for an https web server on this. Please advise. I already have a wildcard cert issued for my domain, the docker container is running, just not on right port, i pulled from URL into the template.

I've tried looking at this, to no avail: https://cloud.google.com/compute/docs/containers/configuring-options-to-run-containers#publishing_co...

 

Thank you.

Solved Solved
0 1 400
1 ACCEPTED SOLUTION

Hi @nc2,

I found a related topic on StackOverflow that covers a similar issue. As per @holdfenytolvaj you need to add or edit the port binding on the hostconfig.json file at the docker. Additionally, after further review, you may also need to add or edit the config.v2.json file to ensure proper configuration. You can pull up those files at /var/lib/docker/containers/<hash_of_the_container>/. Before you add or edit the json files make sure you stop the docker engine.

Here are the steps I follow to add port in the container:

  1. Stop the container.
  2. Stop the docker service.
  3. Restart the docker service.
  4. Edit the hostconfig.json and config.v2.json files (check the given link by @rohitmohta in StackOverflow).
  5. Restart the docker service.
  6. Check/Confirm if the changes on the json file are completed.
  7. Start the docker.

 

#Stop the container.
   docker stop <container_name>

#Stop the docker service.
   sudo systemctl stop docker.socket
   sudo systemctl stop docker

#Restart the docker service.
   sudo systemctl restart docker

#Edit the hostconfig.json and config.v2.json files (check the given link by @rohitmohta in StackOverflow).

#Restart the docker service.
   sudo systemctl restart docker

#Check/Confirm if the changes on the json file are completed.

#Start the docker.
   systemctl enable docker
   systemctl start docker

For config.v2.json, add/edit the “ExposedPorts” under config and “Ports” under the network settings. And for hostconfig.json, add/edit the “PortBindings”

I hope the above information is helpful.

 

View solution in original post

1 REPLY 1

Hi @nc2,

I found a related topic on StackOverflow that covers a similar issue. As per @holdfenytolvaj you need to add or edit the port binding on the hostconfig.json file at the docker. Additionally, after further review, you may also need to add or edit the config.v2.json file to ensure proper configuration. You can pull up those files at /var/lib/docker/containers/<hash_of_the_container>/. Before you add or edit the json files make sure you stop the docker engine.

Here are the steps I follow to add port in the container:

  1. Stop the container.
  2. Stop the docker service.
  3. Restart the docker service.
  4. Edit the hostconfig.json and config.v2.json files (check the given link by @rohitmohta in StackOverflow).
  5. Restart the docker service.
  6. Check/Confirm if the changes on the json file are completed.
  7. Start the docker.

 

#Stop the container.
   docker stop <container_name>

#Stop the docker service.
   sudo systemctl stop docker.socket
   sudo systemctl stop docker

#Restart the docker service.
   sudo systemctl restart docker

#Edit the hostconfig.json and config.v2.json files (check the given link by @rohitmohta in StackOverflow).

#Restart the docker service.
   sudo systemctl restart docker

#Check/Confirm if the changes on the json file are completed.

#Start the docker.
   systemctl enable docker
   systemctl start docker

For config.v2.json, add/edit the “ExposedPorts” under config and “Ports” under the network settings. And for hostconfig.json, add/edit the “PortBindings”

I hope the above information is helpful.