Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

container in VM constantly restarting

If I follow the instructions at https://cloud.google.com/compute/docs/instances/create-start-instance for creating an instance with a container:

```

  1. In the Google Cloud console, go to the VM instances page.

    Go to VM instances

  2. Select your project and click Continue.

  3. Click Create instance.

  4. Specify a Name for your VM. For more information, see Resource naming convention.

  5. In the Container section, click Deploy container.

    1. Specify the Container image to use. For example:

      • To select an NGINX 1.12 container image from Cloud Launcher:

        gcr.io/cloud-marketplace/google/nginx1:1.12

      • To deploy an Apache container image from Docker Hub, always specify the full Docker image name:

        docker.io/httpd:2.4

    2. Optional: Click Advanced container options. For more information, see Configuring options to run your container.

  6. To create the VM, boot the VM, and launch the container, click Create.

```

 

...but I use `ubuntu:22.04` (or a similar public container) I cannot run `docker attach`, because that always produces the error:

 

```

You cannot attach to a restarting container, wait until it is running

```

 

However, the docker container continuously restarts every ~1 minute. 

Regardless of the Docker image (public or on Artifact Registry) and the VM config parameters that I use, the docker container in my running VM continuously restarts. The VM logs do not indicate why this is occurring.

I'm surprised that there isn't more troubleshooting documentation on this, given how easy it has been for me to come across this issue (basically every container & VM setup that I've tried).

2 2 1,285
2 REPLIES 2

Hi @nick-youngblut,

Welcome to Google Cloud Community!

Based on the instructions you followed on this link 

I can give you notes needed to be reviewed before deploying your instance

  1. On Step 5 of the documentation, "To deploy an Apache container image from Docker Hub, always specify the full Docker image name: docker.io/httpd:2.4", you can use "docker.io/ubuntu:22.04" as container image available on docker hub

    Note:
    you can see the official container image with tag on this link 

  2. Please check if you put arguments during startup since it will affect the startup script of the instance on deploying the container. 

    Note: Public container images usually have their own startup config during the process of deploying the container.

  3. You can enable or check following options during creation to automatically create “docker run -dit <container-name> <image-container-id>”
    1. Allocate a buffer for STDIN 
    2. Allocate a pseudo-TTY

You can refer to this image as a reference: 

RonEtch_0-1695324556809.png

Regarding the restarting container during startup of the instance, you can modify the instance by following these steps

  1. Go to Compute Engine and select your instance.
  2. On the tabs above, click Edit 
  3. On the Container, select Change 
  4. Remove any arguments created, click Select
  5. Click, Save and Restart at the bottom of the page.
  6. Once done, you can do SSH again with the instance and try the command “docker attach <instance-name>”.

    Note: Save any changes made since this will restart the instance to modify the startup script for container deployment.

I hope this information is helpful. Please let me know if you have any other questions.

 

"always specify the full Docker image name"

Even at https://hub.docker.com/_/ubuntu/tags?page=1&name=22.04, the full image name is not used: `docker pull ubuntu:22.04`, so how is the user supposed to know that the full image name should be used ("docker.io/ubuntu:22.04")?