lenchv / hive-driver

Driver for connection to Apache Hive via Thrift API
MIT License
40 stars 9 forks source link

Unable to build docker image with .docker files #27

Closed ntallapa12 closed 4 years ago

ntallapa12 commented 4 years ago

Hi, I am trying to run e2e test cases from hive-driver and I am running into this issue. I am on MAC OS (not sure if that. affects docker)

ntalla$ make build cd hive && docker build --build-arg USER_UID=$(id -u) --build-arg USER_GID=$(id -g) -t lenchv/hive:2.3.6 . Sending build context to Docker daemon 8.704kB Step 1/5 : FROM lenchv/base-hive:2.3.6 2.3.6: Pulling from lenchv/base-hive a4d8138d0f6b: Pull complete dbdc36973392: Pull complete f59d6d019dd5: Pull complete 5fee445fce94: Pull complete d270185e6f4d: Pull complete 0ca0b0a3fc43: Pull complete 0e190b96e5cc: Pull complete 2a751f21b6a2: Pull complete d90d5d3aa6fa: Pull complete Digest: sha256:ba3e171f7814d782bf9d716dfea1de0846592841497714b3b1937035ce831c6e Status: Downloaded newer image for lenchv/base-hive:2.3.6 ---> 98242ab2d37a Step 2/5 : ARG USER_UID=1000 ---> Running in e7c1b3bf3513 Removing intermediate container e7c1b3bf3513 ---> 0e63d9acff92 Step 3/5 : ARG USER_GID=1000 ---> Running in 45ddeb081554 Removing intermediate container 45ddeb081554 ---> 1b70c840784a Step 4/5 : RUN groupadd -r hive --gid=$USER_GID && useradd -r -g hive --uid=$USER_UID -d ${HIVE_HOME} hive && chown hive:hive -R ${HIVE_HOME} ---> Running in b0411af8829b groupadd: GID '20' already exists The command '/bin/sh -c groupadd -r hive --gid=$USER_GID && useradd -r -g hive --uid=$USER_UID -d ${HIVE_HOME} hive && chown hive:hive -R ${HIVE_HOME}' returned a non-zero code: 4 make: *** [build] Error 4 ntalla$

Let me know if you see anyth obvious that I may be missing

lenchv commented 4 years ago

Hi @ntallapa12! When container is built it tries to create a user with the same group id and user id as the host system has. It seems that container already has group as your host system.

groupadd: GID '20' already exists

I will fix it. But for now you can define another group id here:

USER_GID=$$(id -g) https://github.com/lenchv/hive-driver/blob/master/.docker/Makefile#L4

ntallapa12 commented 4 years ago

You mean sth like this

cd hive && docker build --build-arg USER_UID=$$(id -u) --build-arg USER_GID=21 -t lenchv/hive:2.3.6 .

After I do above change, I am able to build successfully but in next step "make up TYPE=tcp.plain", I am. getting following errors ntalla0420mac:.docker ntalla$ make up TYPE=tcp.plain rm -f ./confs/hive-site.xml \ && cp ./confs/hive-site.xml.tcp.plain ./confs/hive-site.xml \ && sed "s/HOSTNAME_VALUE/hostname -f/g" docker-compose.yml.dist > docker-compose.yml \ && docker-compose up -d Removing docker_hive-server_1 Removing docker_hive-metastore_1 Recreating 06b8ef750eb8_docker_hive-server_1 ... docker_openldap_1 is up-to-date Recreating 320d70dc5fe8_docker_hive-metastore_1 ... error Recreating 06b8ef750eb8_docker_hive-server_1 ... error ERROR: for 320d70dc5fe8_docker_hive-metastore_1 Cannot start service hive-metastore: unable to find user hive: no matching entries in passwd file

ERROR: for 06b8ef750eb8_docker_hive-server_1 Cannot start service hive-server: unable to find user hive: no matching entries in passwd file

ERROR: for hive-metastore Cannot start service hive-metastore: unable to find user hive: no matching entries in passwd file

ERROR: for hive-server Cannot start service hive-server: unable to find user hive: no matching entries in passwd file ERROR: Encountered errors while bringing up the project. make: *** [up] Error 1 ntalla0420mac:.docker ntalla$

ntallapa12 commented 4 years ago

ohk, since I dont need ssl, I skipped the step "make generate_ssl", is that required step? And one more. question: When we run "make build", will that keep running on that terminal and do we have to open other terminal to other commands ? I didnt see it finishing, want to confirm

lenchv commented 4 years ago

@ntallapa12 no, if you don't need ssl, it is not required to generate it.

When you build you just configure the image lenchv/hive:2.3.6. Then the command make up adjust hostname in docker-compose.yml.dist and starts services docker-compose up -d. It is strange that user "hive" not found, as it is added in the image.

You can try omit building image, remove or rename built image: docker image rm lenchv/hive:2.3.6

And then run make up TYPE=tcp.plain

In this case the image will be got from docker hub. The difference is that, in the image from docker hub the user hive has id 1000, which may be different from yours. The possible problem is that if you will share files between container and your host machine it will have different permissions. For instance, it won't have enough permissions to use hive-site.xml

Also, to troubleshoot you may run container and check what is wrong with user:

docker run --rm -it lenchv/hive:2.3.6 bash