How do I develop inside a Docker container running on a Droplet using Visual Studio Code Remote Containers?

Posted December 4, 2019 2.2k views
DockerLinux CommandsDevelopment


I am new to Docker containers and would like to know if this is an appropriate way to setup my development and production workflow.

I would like to setup two Docker containers:

  1. Docker container-1 (Droplet #1): Development
  2. Docker container-2 (Droplet #2): Production

I would like to then connect to each of the containers using Visual Studio Code’s Remote Containers, where I can develop remotely on container-1, and when I’m ready for production, can push the container to the production droplet running Docker also.

Would anyone be able to provide me a brief high-level overview of how I would go about setting this up on DigitalOcean.

As a secondary question, would I be better off going Kubernetes rather than two droplets only running Docker.

edited by bobbyiliev

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Usually you should not really do that, containers are supposed to be immutable, meaning that you just deploy them and do not make the changes to the container but instead make the changes locally, build a new image with the new changes and then deploy the image.

Another thing that you could do is have a Docker volume and a mount and store your files in that mount, that way you would be making the changes and they would be saved in the volume rather than just on the Docker container storage layer.

This is also good because if your container gets deleted your files would be stored in the volume and can be reused.

I need to attach to Docker container running in a droplet too. In my case, I need to debug issue that only occurs in PROD.

Any suggestions would be appreciated.