Use script in docker compose

I edited your post to add code blocks. Please, format your posts next time according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.

I don’t get it. Where exactly are you trying to use that docker cp? I hope not in the “command” parameter in the compose file. That is for commands running inside the container.

And you don’t even need to copy if you can mount as you mount volumes. There are some examples here:

https://docs.docker.com/compose/compose-file/05-services/#volumes

Never copy files into a running container, especially not dependencies. Everything will disappear when you delete the container. You could create your own Dockerfile and build your own image that already has that dependency.

1 Like