Copy asset with location found via shell function

I have an asset which needs to be copied to the docker image, but whose location I do not know beforehand: I need to run a shell command to find it:

where-is-my-asset

How can this be combined with the COPY command in a Dockerfile? Usually I do:

  • can't link nginx with ghost in docker
  • Docker log in command does not work
  • Can I run a .Net web application on Dockers for windows?
  • how to catch the exit event of process in docker
  • Task on marathon never ends
  • Why Docker does not destroy the hidden layers?
  • COPY app.json /usr/src/app
    

    But now I need to do:

    COPY `where-is-my-asset` /usr/src/app
    

  • How to find exposed port of linked service with Docker Compose v2 format?
  • Docker: Add a restart policy to a container that was already created
  • architecture for multiple nginx/php apps using docker
  • Syn flood and net.ipv4.tcp_syncookies
  • Docker Swarm - Map ports and Scaling
  • Node error ENOSPC when running pm2 with docker-compose
  • One Solution collect form web for “Copy asset with location found via shell function”

    ARG will let you define a dynamic argument to the build but I don’t believe you can run a command in the Dockerfile to populate the argument.

    You could source it beforehand. With a Dockerfile like…

    FROM busybox
    ARG assetfile
    COPY $assetfile /somehwere
    

    Then run

    docker build --build-arg assetfile="$(where-is-my-asset)" .
    

    Which is not much different to just doing it in the shell.

    cp "$(where-is-my-asset)" .
    docker build .
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.