<p>I'm trying to create a pod with Postgres. After initialize, the Pod has to execute the following command:</p>

<pre><code>    "lifecycle": {
      "postStart": {
        "exec": {
          "command": [
            "export", "PGPASSWORD=password;", "psql", "-h", "myhost", "-U", "root", "-d", "AppPostgresDB", "&lt;", "/db-backup/backup.sql"
          ]
        }
      }
    },     
</code></pre>

<p>Without these command the pod works perfectly.</p>

<p>I get the following status:</p>

<pre><code>NAME              READY     STATUS         RESTARTS   AGE
postgres-import   0/1       ExitCode:137   0          15s
</code></pre>

<p>I get these events:</p>

<pre><code>Mon, 16 Nov 2015 16:12:50 +0100 Mon, 16 Nov 2015 16:12:50 +0100 1   {kubelet ip-10-0-0-69.eu-west-1.compute.internal}   spec.containers{postgres-import}    created     Created with docker id cfa5f8177beb
Mon, 16 Nov 2015 16:12:50 +0100 Mon, 16 Nov 2015 16:12:50 +0100 1   {kubelet ip-10-0-0-69.eu-west-1.compute.internal}   spec.containers{postgres-import}    killing     Killing with docker id 15ad0166af04
Mon, 16 Nov 2015 16:12:50 +0100 Mon, 16 Nov 2015 16:12:50 +0100 1   {kubelet ip-10-0-0-69.eu-west-1.compute.internal}   spec.containers{postgres-import}    started     Started with docker id cfa5f8177beb
Mon, 16 Nov 2015 16:13:00 +0100 Mon, 16 Nov 2015 16:13:00 +0100 1   {kubelet ip-10-0-0-69.eu-west-1.compute.internal}   spec.containers{postgres-import}    killing     Killing with docker id cfa5f8177beb
Mon, 16 Nov 2015 16:13:00 +0100 Mon, 16 Nov 2015 16:13:00 +0100 1   {kubelet ip-10-0-0-69.eu-west-1.compute.internal}   spec.containers{postgres-import}    created     Created with docker id d910391582e9
Mon, 16 Nov 2015 16:13:01 +0100 Mon, 16 Nov 2015 16:13:01 +0100 1   {kubelet ip-10-0-0-69.eu-west-1.compute.internal}   spec.containers{postgres-import}    started     Started with docker id d910391582e9
Mon, 16 Nov 2015 16:13:11 +0100 Mon, 16 Nov 2015 16:13:11 +0100 1   {kubelet ip-10-0-0-69.eu-west-1.compute.internal}   spec.containers{postgres-import}    killing     Killing with docker id d910391582e9
</code></pre>

<p>What can I do to solve this issue?
Thanks</p>

<p>Try passing this to the shell:</p>

<pre><code>"command": [
  "/bin/bash", "-c", "export PGPASSWORD=password; psql -h myhost -U root -d AppPostgresDB &lt; /db-backup/backup.sql"
]
</code></pre>
