Search code examples
dockerdockerfileoracle-call-interfaceoracle-cloud-infrastructure

Run OCI CLI command from dockerfile


I have a question about Oracle OCI CLI. I create an image (LINK) that contain all necessary to start working with oracle cloud. You have to modify config file just to start using all from Oracle cloud.

Or you can set your ora cloud environment with:

oci setup config

but i want to to execute some OCI commands with dockerfile, but is really complex, i can't do it work. I'm doing this

FROM juliovg/oracle-oci-19
ENV HOME_DIR=/root \ 
CODE_DIR=/root/sample/code \
BUCKET_NAME=Code
WORKDIR $HOME_DIR
RUN rm -rf $HOME_DIR/.oci
RUN wget "<.OCI_FILE_URL_UPLOADED_INTO_A_BUCKET>/my_key.tar.gz"
RUN tar -xvf my_key.tar.gz && rm -rf my_key.tar.gz
RUN mkdir -p $CODE_DIR
RUN cd $CODE_DIR
RUN touch my_file.txt

RUN oci os bucket create -c <MY_COPARTMENT> --name <NEW_BUCKET_NAME>

And this is the error -->

enter image description here

I need execute some OCI commands at the begging with RUN or CMD (i try both)

Notes: OCI_FILE_URL_UPLOADED_INTO_A_BUCKET is a zip file that contains the configuration made with another computer, the idea is share the same key with several users , when the use the juliovg/oracle-oci-19 with another thinks


Solution

  • Seems like path issue, dockerfile RUN command call executable like /bin/sh -c executable. so better to give the full path of the executable like RUN /root/bin/oci -v.

    FROM juliovg/oracle-oci-19
    ENV HOME_DIR=/root \ 
    CODE_DIR=/root/sample/code \
    BUCKET_NAME=Code
    WORKDIR $HOME_DIR
    RUN rm -rf $HOME_DIR/.oci
    RUN mkdir -p $CODE_DIR
    RUN cd $CODE_DIR
    RUN touch my_file.txt
    ENV LC_ALL=en_US.utf-8
    ENV LANG=en_US.utf-8
    RUN /root/bin/oci -v
    RUN /root/bin/oci os bucket create -c MY_COPARTMENT --name NEW_BUCKET_NAME