# How do I save updated container?

**URL:** <https://community.codefresh.io/t/how-do-i-save-updated-container/499>\
**Category:** Pipeline Workflows\
**Created:** [February 9, 2021, 4:49pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499 "2021-02-09T16:49:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![valwork2021](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/valwork2021/32/328_2.png) [@valwork2021](https://community.codefresh.io/u/valwork2021)\
**Post date:** [February 9, 2021, 4:49pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/1 "2021-02-09T16:49:00Z")

</div>

I updated Docker container.  
How do I publish it?

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [February 10, 2021, 10:28am UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/2 "2021-02-10T10:28:39Z")

</div>

You can use the push step to push any container to your registry.

- [Build and Push an Image · Codefresh | Docs](https://codefresh.io/docs/docs/yaml-examples/examples/build-and-push-an-image/)
- [Push step · Codefresh | Docs](https://codefresh.io/docs/docs/codefresh-yaml/steps/push/)

I assume that by “updated” you mean you changed the dockerfile. Or do you mean something else?

---

<div class="post-metadata">

**Author:** ![valwork2021](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/valwork2021/32/328_2.png) [@valwork2021](https://community.codefresh.io/u/valwork2021)\
**Post date:** [February 16, 2021, 4:19pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/3 "2021-02-16T16:19:05Z")

</div>

Not dockerfile.  
Container.

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [February 17, 2021, 7:54am UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/4 "2021-02-17T07:54:52Z")

</div>

You can use the docker save/export commands.

- [docker export | Docker Documentation](https://docs.docker.com/engine/reference/commandline/export/)
- [docker save | Docker Documentation](https://docs.docker.com/engine/reference/commandline/save/)

However, you won’t normally use these commands with Codefresh

Can you explain a bit what you are trying to do and what is your use case?

---

<div class="post-metadata">

**Author:** ![valwork2021](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/valwork2021/32/328_2.png) [@valwork2021](https://community.codefresh.io/u/valwork2021)\
**Post date:** [March 3, 2021, 12:36pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/5 "2021-03-03T12:36:29Z")

</div>

I am loading data into database for integration tests.  
This happens four times in a pipeline - for four configurations.

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [March 3, 2021, 1:08pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/6 "2021-03-03T13:08:45Z")

</div>

For loading data into databases we suggest this approach [Populate a database with existing data · Codefresh | Docs](https://codefresh.io/docs/docs/yaml-examples/examples/populate-a-database-with-existing-data/)

It doesn’t modify the container itself. It simply loads data to a running container.

---

<div class="post-metadata">

**Author:** ![valwork2021](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/valwork2021/32/328_2.png) [@valwork2021](https://community.codefresh.io/u/valwork2021)\
**Post date:** [March 4, 2021, 7:28pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/7 "2021-03-04T19:28:12Z")

</div>

My use case is to deploy database with test data to Kubernetes, for UAT.  
The test data is loaded by a Java+Gradle program.  
So the approach above does not work for me.

---

<div class="post-metadata">

**Author:** ![valwork2021](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/valwork2021/32/328_2.png) [@valwork2021](https://community.codefresh.io/u/valwork2021)\
**Post date:** [March 4, 2021, 7:33pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/8 "2021-03-04T19:33:20Z")

</div>

An example of YAML that uses Docker commands commit and push would be helpful.

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [March 5, 2021, 7:31am UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/9 "2021-03-05T07:31:14Z")

</div>

You cannot run direct Docker commands in Codefresh for security reasons. However I don’t see any complication with your case. Just package your Gradle/Java program in a docker image on its own

Then

```auto
 run_my_db_tests:
    stage: test
    image: 'maven:3.5.2-jdk-8-alpine'
    title: "Running integration tests"
    commands:
      - 'mvn integration-test'
    services:
      composition:
        my_postgresql_db:
          image: postgres:11.5
          ports:
            - 5432 
      setup:
        image: 'my-java-app-that-loads-data'
        commands:
          - "gradle load-my-data-in-the-db-task"

```

In the example above the docker image my-java-app-that-loads-data contains your app with gradle.

Would that work for you?

---

<div class="post-metadata">

**Author:** ![valwork2021](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/valwork2021/32/328_2.png) [@valwork2021](https://community.codefresh.io/u/valwork2021)\
**Post date:** [March 5, 2021, 2:43pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/10 "2021-03-05T14:43:15Z")

</div>

No.  
Deployed to Kubernetes SQL Server image should contain test data.

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [March 8, 2021, 9:00am UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/11 "2021-03-08T09:00:35Z")

</div>

Postgresql was just an example. You can use any db that you want that is packaged in a Docker image.

```auto
run_my_db_tests:
    stage: test
    image: 'maven:3.5.2-jdk-8-alpine'
    title: "Running integration tests"
    commands:
      - 'mvn integration-test'
    services:
      composition:
        my_mssql_db:
          image: mcr.microsoft.com/mssql/server:2019-latest
          ports:
            - 1433 
      setup:
        image: 'my-java-app-that-loads-data'
        commands:
          - "gradle load-my-data-in-the-db-task"

```

---

<div class="post-metadata">

**Author:** ![valwork2021](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/valwork2021/32/328_2.png) [@valwork2021](https://community.codefresh.io/u/valwork2021)\
**Post date:** [March 8, 2021, 1:41pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/12 "2021-03-08T13:41:53Z")

</div>

How do I deploy updated SQL Server container to Kubernetes?

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [March 8, 2021, 5:48pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/13 "2021-03-08T17:48:12Z")

</div>

Hello

The example I posted was about your use case where you said that a gradle/java project is loading data into your SQL server. Correct? If that is the case, I don’t see how you can have an updated container.

1. You deploy the SQL container in Kubernetes as is
2. You run the Gradle/Java program that loads data in the database. At this point the fact that the database is in a container or it is running in Kubernetes doesn’t matter anymore
3. The database has the test data and you can do whatever you want with it. That’s it.

There is no need actually update a container on the spot or redeploy a changed container.

Can you offer some more insights on what exactly your requirements are?  
Also can I ask what process did you have before moving to Kubernetes? Or is this a greenfield project?

---

<div class="post-metadata">

**Author:** ![valwork2021](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/valwork2021/32/328_2.png) [@valwork2021](https://community.codefresh.io/u/valwork2021)\
**Post date:** [March 8, 2021, 9:51pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/14 "2021-03-08T21:51:40Z")

</div>

> [@Kostis](#):
>
> You run the Gradle/Java program that loads data in the database. At this point the fact that the database is in a container or it is running in Kubernetes doesn’t matter anymore

How do I load data into database running in Kubernetes?

---

<div class="post-metadata">

**Author:** ![valwork2021](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/valwork2021/32/328_2.png) [@valwork2021](https://community.codefresh.io/u/valwork2021)\
**Post date:** [March 8, 2021, 9:54pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/15 "2021-03-08T21:54:09Z")

</div>

> [@Kostis](#):
>
> Can you offer some more insights on what exactly your requirements are?

Once a day build and deploy database and webapp to Kubernetes for UAT.  
Database data and webapp come from a repo and must match.

> [@Kostis](#):
>
> Or is this a greenfield project?

Yes.

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [March 9, 2021, 10:27am UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/16 "2021-03-09T10:27:49Z")

</div>

> [@valwork2021](#):
>
> How do I load data into database running in Kubernetes?

Once you deploy any application to Kubernetes you can optionally expose it to outside connections. If for example your cluster is at 53.124.239.149 and you deploy an mssql server, you can make it listen at 53.124.239.149:1433

After that you can connect to it with any tool that supports mssql or use your Gradle app to load data. The fact that the db is running on Kubernetes is irrelevant to the connecting application.

There are many ways to expose it but the simplest one is to use a [loadbalancer](https://kubernetes.io/docs/concepts/services-networking/). See an example here [https://github.com/codefresh-contrib/gitops-kubernetes-configuration/blob/master/service.yml](https://github.com/codefresh-contrib/gitops-kubernetes-configuration/blob/master/service.yml) . If you are using Kubernetes on the cloud, be sure to check the pricing first as using a Load balancer will affect your billing.

Exposing a Kubernetes application is not related to Codefresh pipelines. I suggest you do the loading of data first manually so that you understand Kubernetes networking and then add Codefresh in the mix instead of trying to make all things work at the same time.

Does that help?

---

<div class="post-metadata">

**Author:** ![valwork2021](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/valwork2021/32/328_2.png) [@valwork2021](https://community.codefresh.io/u/valwork2021)\
**Post date:** [March 16, 2021, 9:47pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/17 "2021-03-16T21:47:56Z")

</div>

How do I load data into database running in Kubernetes using CF pipeline?

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [March 17, 2021, 5:36am UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/18 "2021-03-17T05:36:25Z")

</div>

```
load_data:
    image: 'gradle:4.7.0-jdk8-alpine'
    title: "Loading data in the db"
    commands:
      - 'gradle load-my-data-in-the-db-task'

```

---

<div class="post-metadata">

**Author:** ![valwork2021](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/valwork2021/32/328_2.png) [@valwork2021](https://community.codefresh.io/u/valwork2021)\
**Post date:** [March 17, 2021, 7:02pm UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/19 "2021-03-17T19:02:03Z")

</div>

How do I get IP address of the Kubernetes service the previous step deployed to?

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [March 19, 2021, 8:22am UTC](https://community.codefresh.io/t/how-do-i-save-updated-container/499/20 "2021-03-19T08:22:19Z")

</div>

You shouldn’t use IP addresses because they change all the time. You need to setup DNS in your Kubernetes cluster, so that you use a hostname like “[my-db.my-kubernetes-cluster.com](http://my-db.my-kubernetes-cluster.com)” or “[my-app.my-kubernetes-cluster.com](http://my-app.my-kubernetes-cluster.com)”

If you insist on getting the IP it should something like

```auto
kubectl get svc my-service -n my-namespace -o jsonpath='{.status.loadBalancer.ingress[0].ip}'

```
