Nupur Bansal
Nupur Bansal

Reputation: 21

pkg_config_path error on building with docker

When I am building an image for my Go application through docker, I am getting the following error:

# pkg-config --cflags oci8

Package oci8 was not found in the pkg-config search path. Perhaps you should add the directory containing `oci8.pc' to the PKG_CONFIG_PATH environment variable No package 'oci8' found pkg-config: exit status 1

I have set the environment variable in my Dockerfile also. But still the issue persists. My Dockerfile is:

*FROM golang:1.9
ARG app_env
ENV APP_ENV $app_env
ENV GOPATH /home/nupur/mapi-go
ENV PKG_CONFIG_PATH /home/nupur/mapi-go
ENV ORACLE_HOME /usr/include/oracle/11.2/client64
ENV LD_LIBRARY_PATH /usr/lib/oracle/11.2/client64/lib
WORKDIR /home/nupur/mapi-go/src/DockerApp/blDocker
ADD . .
RUN go build /home/nupur/mapi-go/src/DockerApp/blDocker/launch.go
ENTRYPOINT ["./launch"]
EXPOSE 8093*

Please suggest a solution.

Upvotes: 2

Views: 5011

Answers (2)

Ayush C.
Ayush C.

Reputation: 54

Package oci8 was not found in the pkg-config search path.

Since a Go Lang image is being used, the unix package pkg-config cannot be accessed here. You could instead use an Ubuntu image and install the relevant package via the apt package manager.

FROM ubuntu:22.04
RUN apt update
RUN apt install -y pkg-config
RUN apt install -y golang

Upvotes: 0

SinHub
SinHub

Reputation: 21

I am not sure had you solved this problem cause this problem has been asked two years ago ... From your Dockerfile, you already set the PKG_CONFIG_PATH, but after setting WORKDIR you used ADD command, so you add files to your WORKDIR that does not include your PKG_CONFIG_PATH. I think you should use ls for your PKG_CONFIG_PATH to see if any file called oci8.pc exited. In this case I suggest to use COPY command to move oci.pc to PKG_CONFIG_PATH specially.

Upvotes: 2

Related Questions