Restarting container instance

vamsi koppolu 0 Reputation points
2024-03-29T11:05:56.4966667+00:00

Hi, I have a problem with Container Instance that was created on Azure.

Each time I restart the container, it just reset all the data on it.

For example, I installed Vim on it, but after restart, it can't run Vim command.

Do you have any idea how can I fix the issue?

FYI: I am using the gitblit image from Docker Hub.

Thanks

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
669 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Konstantinos Passadis 17,381 Reputation points MVP
    2024-03-29T11:15:27.68+00:00

    hello @vamsi koppolu

    This is the way Container instances are build

    They are designed to be ephemeral and stateless, which means any changes made within the container's filesystem are lost once the container is restarted or deleted.

    To resolve this issue, you have a few options:

    1. Create a Custom Image: Modify the existing gitblit Docker image to include Vim (or any other changes you need) by creating a custom Dockerfile. In your Dockerfile, start from the gitblit image and add the necessary commands to install Vim. Build this image and push it to a Docker registry (like Docker Hub or Azure Container Registry). Use this custom image for your Azure Container Instance. Example Dockerfile:
         DockerfileCopy code
         FROM gitblit/gitblit
      

    RUN apt-get update && apt-get install -y vim

       
    1. Move to Container Apps or Web Apps or AKS. This way you maintain your Image build with the way you prefer
    
    --
    
    I hope this helps!
    
    The answer or portions of it may have been assisted by AI Source: ChatGPT Subscription
    
    Kindly mark the answer as __Accepted__ and __Upvote__ in case it helped!
    
    Regards
    
    0 comments No comments

  2. v-vvellanki-MSFT 4,915 Reputation points Microsoft Vendor
    2024-03-29T11:21:57.37+00:00

    Hi @vamsi koppolu,

    Thanks for contacting Microsoft Q&A platform.

    When you use docker run to start a container, it actually creates a new container based on the image you have specified. So, if you want to see the changes made, you can restart an existing container. docker ps -a shows you also the ones that have exited. Select the correct container and restart it to see the changes made before the last exit.

    Hope this helps you.

    0 comments No comments