Initialize Cloudera Hive Docker Container With Data

痴心易碎 提交于 2020-01-02 20:18:58

问题


I am running the Cloudera suite in a Docker Container using the image described here: https://hub.docker.com/r/cloudera/quickstart/

I have the following configuration:

Dockerfile

FROM cloudera/quickstart:latest

Docker Compose file

version: '3.1'
services:

  db-hive:
    container_name: mobydq-test-db-hive
    image: mobydq-test-db-hive
    restart: always
    build:
      context: .
      dockerfile: ./db-hive/Dockerfile
    expose:
      - 10000
    networks:
      - default
    hostname: quickstart.cloudera
    privileged: true
    tty: true
    command: ["/usr/bin/docker-quickstart"]

networks:
  default:
    external:
      name: mobydq-network

When the container start, I would like it creates automatically a new database, a table and populates it with data. What would be the best way to do that?


回答1:


The solution I have found is to copy the content of the script /user/bin/docker-quickstart into a new shell script entrypoint.sh. Then I added the Create table and Insert statements directly in the entrypoint.sh.

Example here: https://github.com/mobydq/mobydq/blob/master/test/db-hive/init/entrypoint.sh

Finally I run the command entrypoint.sh in the docker compose file instead of the quickstart script.



来源:https://stackoverflow.com/questions/53140046/initialize-cloudera-hive-docker-container-with-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!