How to execute Linux command in host-machine and copy the output to image build by docker file?

94 Views Asked by At

I want to copy the my.cnf file present in the host server to child docker image wherever I run docker file that uses a custom base image having below command.

ONBUILD ADD locate -i my.cnf|grep -ioh 'my.cnf'|head -1 /

but above line is breaking docker file. Please share correct syntax or alternatives to achieve the same.

1

There are 1 best solutions below

0
Max On

Unfortunately, you can't declare host commands inside your Dockerfile. See Execute command on host during docker build .

Your best bet is probably to tweak your deployment scripts to locate my.cnf on the host before running docker build.