Answers: <p>One way to use curl inside the container will be to use a custom Dockerfile to build you postgrsql container.
  Just use the <code>image: postgres:12-alpine</code> as the base image of your Dockerfile and install curl in alpine with the following command : <code>RUN apk --no-cache add curl</code></p>
  
Answers: CC BY-SA 4.0
Answers: 2020-08-28T07:43:34.177Z
Answers: 2020-08-28T07:43:34.177Z
Answers: RASOANAIVO Alindrianja
Body: <p>Using <code>COPY table FROM PROGRAM 'curl &quot;www.example.com/data.csv&quot;';</code> I am able to copy a CSV directly from the web into a psql table.</p>
  <p>However, when I am running the same command from inside a docker container I get the following error:</p>
  <pre><code>COPY sites FROM PROGRAM 'curl &quot;www.example.com/data.csv&quot;'; 
  ERROR:  program &quot;curl &quot;www.example.com/data.csv&quot;&quot; failed
  DETAIL:  command not found
  </code></pre>
  <p>Obviously curl is not available in the containerized environment. Therefore I changed my Postgres Docker image from <code>image: postgres:12-alpine</code> to <code>image: postgres-12</code>. Unfortunately I still get the same error.</p>
  <p>How can include the <code>curl</code> command in a containerized PostgreSQL Docker environment?</p>
  <p>This is my docker-compose file:</p>
  <pre><code>version: '3.7'
  
  services:
    web:
      build:
        context: ./services/web
        dockerfile: Dockerfile.prod
      command: gunicorn --bind 0.0.0.0:5000 manage:app
      volumes:
        - static_volume:/home/app/web/project/static
        - media_volume:/home/app/web/project/media
      expose:
        - 5000
      env_file:
        - ./.env.prod
      depends_on:
        - db
    db:
      image: postgres:12
      volumes:
        - postgres_data:/var/lib/postgresql/data/
      env_file:
        - ./.env.prod.db
    nginx:
      build: ./services/nginx
      volumes:
        - static_volume:/home/app/web/project/static
        - media_volume:/home/app/web/project/media
      ports:
        - 1337:80
      depends_on:
        - web
  Include curl commands in a PostgreSQL Docker environment
  volumes:
    postgres_data:
    static_volume:
    media_volume:
  
  </code></pre>
  
Tags: <docker><docker-compose><databases><images><postgresql>
Title: Include curl commands in a PostgreSQL Docker environment
UserDisplayName: sir_olf
ThreadText: # Include curl commands in a PostgreSQL Docker environment
  
  (Asked by: username_0 on 2020-08-27)
  
  Using `COPY table FROM PROGRAM 'curl "www.example.com/data.csv"';` I am able to copy a CSV directly from the web into a psql table.
  
  However, when I am running the same command from inside a docker container I get the following error:
  
  ```
  COPY sites FROM PROGRAM 'curl "www.example.com/data.csv"'; 
  ERROR:  program "curl "www.example.com/data.csv"" failed
  DETAIL:  command not found
  
  ```
  
  Obviously curl is not available in the containerized environment. Therefore I changed my Postgres Docker image from `image: postgres:12-alpine` to `image: postgres-12`. Unfortunately I still get the same error.
  
  How can include the `curl` command in a containerized PostgreSQL Docker environment?
  
  This is my docker-compose file:
  
  ```
  version: '3.7'
  
  services:
    web:
      build:
        context: ./services/web
        dockerfile: Dockerfile.prod
      command: gunicorn --bind 0.0.0.0:5000 manage:app
      volumes:
        - static_volume:/home/app/web/project/static
        - media_volume:/home/app/web/project/media
      expose:
        - 5000
      env_file:
        - ./.env.prod
      depends_on:
        - db
    db:
      image: postgres:12
      volumes:
        - postgres_data:/var/lib/postgresql/data/
      env_file:
        - ./.env.prod.db
    nginx:
      build: ./services/nginx
      volumes:
        - static_volume:/home/app/web/project/static
        - media_volume:/home/app/web/project/media
      ports:
        - 1337:80
      depends_on:
        - web
  Include curl commands in a PostgreSQL Docker environment
  volumes:
    postgres_data:
    static_volume:
    media_volume:
  
  ```
  
  **Tags:** docker, docker-compose, databases, images, postgresql
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-08-28. Score: 3
  
  One way to use curl inside the container will be to use a custom Dockerfile to build you postgrsql container.
  Just use the `image: postgres:12-alpine` as the base image of your Dockerfile and install curl in alpine with the following command : `RUN apk --no-cache add curl`
  
  
  ---
  
  