1

I want to create docker containers for my microservices. I'm doing this mostly as a learning exercise and as a requirement for my workspace. I'm developing and iterating on my microservices and tracking dependencies on my host will be a nightmare.

So, I have a git repository for every microservice. Originally, I was mounting local directories of these repositories onto each container. I was using my text editor on my local machine and then watching the file changes through docker. While this worked, it was way too slow for the file watcher (you can see many people have this problem especially with Docker for Mac).

I decided to take what I thought was the 'better practice' route. I cloned the individual repositories in my docker build. So far, my pages are being loaded much quicker :)

Now I have the dilemma of deciding how to best work on these files in my containers. If I use any sort of mounting, I can see my local files on my container, but not vice versa. Obviously, this is not good because I can't edit them using my fancy VSCode on my local machine.

If not through git, mounting, etc. what is the best way to work on my microservice files so that they're quick to load?

Edit: The only solution seems to be docker-sync. But considering the overhead and the lack of official support, I probably won't be pursuing it. Hope it does help someone though

db2791
  • 1,040
  • 6
  • 17
  • 30
  • If I understand you correctly, you want to edit files inside containers, you can do this by logging into container. – Ubercool Mar 07 '18 at 05:20
  • 1
    I have written an answer here: [Using an IDE while developing on a docker container](https://stackoverflow.com/a/48785303/1561148) which may help. – tgogos Mar 07 '18 at 08:42

1 Answers1

2

You should take a look at Volumes. I believe this will give you both the "good practice" and "performance boost" you're looking for.

Volumes can be easily shared between containers, meaning that handling your data is much easier to do than mounted (or binded) volumes.

I recommend you check out this thread for more information on the matter.

EDIT Check out this section in the Docker Docs.

guychouk
  • 671
  • 1
  • 8
  • 28