1.

Should I Include My Code With Copy/add Or A Volume?

Answer»

You can add your code to the image using COPY or ADD directive in a Dockerfile. This is USEFUL if you need to relocate your code along with the Docker image, for example when you’re sending code to another ENVIRONMENT (PRODUCTION, CI, etc).

You should use a volume if you want to make changes to your code and see them reflected immediately, for example when you’re developing code and your SERVER supports hot code reloading or live-reload.

There may be cases where you’ll want to use both. You can have the image include the code using a COPY, and use a volume in your Compose file to include the code from the host during development. The volume OVERRIDES the directory contents of the image.

You can add your code to the image using COPY or ADD directive in a Dockerfile. This is useful if you need to relocate your code along with the Docker image, for example when you’re sending code to another environment (production, CI, etc).

You should use a volume if you want to make changes to your code and see them reflected immediately, for example when you’re developing code and your server supports hot code reloading or live-reload.

There may be cases where you’ll want to use both. You can have the image include the code using a COPY, and use a volume in your Compose file to include the code from the host during development. The volume overrides the directory contents of the image.



Discussion

No Comment Found