2

I'm trying to install and configure nginx among other things, but I need to copy an entire config file. I tried simply adding it to the Dockerfile since it's just a few lines, but Dockerfile doesn't seem to have good support for multiline commands. I mean I need to copy my config file as is, I can't pollute it with 'sed', 'cat', or '\' on every line.

Some people suggested placing the config file in a public git repository, and I guess I can do that if it turns out there is no other way. But I don't like it at all because it doesn't make sense. I don't want to have and manage version control repositories for these files (let alone make them public), I just want to copy/paste them. They are very simple!

Any ideas?

ChocoDeveloper
  • 14,160
  • 26
  • 79
  • 117

1 Answers1

6

You should use the ADD instruction in your Dockerfile to copy the config file into the container.

Simon Warta
  • 10,850
  • 5
  • 40
  • 78
Ben Whaley
  • 32,811
  • 7
  • 87
  • 85
  • 1
    Note: generally, it is better to use COPY instead of ADD unless you specifically need how ADD handles tarballs. See [this answer](https://stackoverflow.com/a/24958548/9161344) and [Dockerfile best practices](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#add-or-copy). – ascendants Apr 17 '20 at 15:45