It is very easy to setup volume sharing in docker. You ideally want the following folders to be shared when a new docker is initialized for you:

  • /var/log so that you can keep track of logs
  • nginx specific folders because you will have two instances of nginx running - one on docker and another on EC2. This allows you to share logs
  • your personal workspace or anything that you’d like to share

Here’s how you’d do it. The keyword is VOLUME… in your Dockerfile

VOLUME [ \
    "/var/shared/", \ 
    "/etc/nginx/sites-enabled", \ 
    "/var/log/nginx", \
    "/ws/" \
]