<p>We use kubernetes / minikube rather than docker-compose, but its the same problem. 
We generally go with option #1 as:</p>

<ul>
<li>Development is 99% getting the app right.</li>
<li>You want to be able to iterate fast/freely with your app.</li>
<li>You want easy use of your debugger / IDE without inhibition.</li>
<li>It lets you avoid configuring / managing remote debuggers from within the docker container.

<ul>
<li>If you did this in the container, you'd have to worry about making sure you didn't actually put it in prod as it can be harmful; see below.</li>
</ul></li>
</ul>

<p>For most code changes, we actually just have GitLab-CI set up so that it test-builds/deploys the container/app on check in (on their own branch/space).  That way, most developers don't even need to think about the container part unless they're making mods to that area.  But, obviously you'd still want them being able to run the MySQL container locally and easily.</p>

<h3>Remote Debugging Info</h3>

<p><a href="https://jaxenter.com/remote-debugging-java-applications-151466.html" rel="nofollow noreferrer">https://jaxenter.com/remote-debugging-java-applications-151466.html</a></p>

<blockquote>
  <p><strong>Warning: Don’t keep remote debugging JVM arguments ON always, as it has following downsides:</strong></p>
  
  <p>Remote debugging mode disables several optimizations that JVM does to application to optimize the performance. All those optimizations will be lost.
  Remote debugging opens up a port. It’s a security risk, as anyone who can hit the server can initiate remote debugging</p>
</blockquote>

CC BY-SA 4.0
2020-03-10T16:19:33.243Z
2020-03-10T16:19:33.243Z
John Humphreys
<p>I have a couple of questions related to the usage of Docker in a development environment. I am going to propose three different scenarios of how I think Docker could be used in a development environment. Let's imagine that we are creating a REST API in Java and Spring Boot. For this, I will need a MySQL database.</p>

<ol>
<li><p>The first scenario is to have a docker-compose for development with the MySQL container and a production docker-compose with MySQL and the Java application (jar) in another container. To develop I launch the docker-compose-dev.yml to start only the database. The application is launched and debugged using the IDE, for example, IntelliJ Idea. Any changes made to the code, the IDE will recognize and relaunch the application by applying the changes.</p></li>
<li><p>The second scenario is to have, for both the development and production environment, a docker-compose with the database and application containers. That way, every time I make a change in the code, I have to rebuild the image so that the changes are loaded in the image and the containers are launched again. This scenario may be the most typical and used for development with Docker, but it seems very slow due to the need to rebuild the image every time there is a change.</p></li>
<li><p>The third scenario consists of a mixture of the previous two. Two docker-compose. The development docker-compose contains both containers, but with mechanisms that allow a live reload of the application, mapping volumes and using, for example, Spring Dev Tools. In this way, the containers are launched and, in case of any change in the files, the application container will detect that there is a change and will be relaunched. For production, a docker-compose would be created simply with both containers, but without the functionality of live reload. This would be the ideal scenario, in my opinion, but I think it is very dependent on the technologies used since not all allow live reload.</p></li>
</ol>

<p>The questions are as follows.</p>

<ul>
<li><p>Which of these scenarios is the most typical when using Docker for development?</p></li>
<li><p>Is scenario 1 well raised? That is, dockerize only external services, such as databases, queues, etc. and perform the development and debugging of the application with the IDE without using Docker for it.</p></li>
</ul>

<p>The doubts and the scenarios that I raise came up after I raised the problem that scenario 2 has. With each change in the code, having to rebuild the image and start the containers again is a significant waste of time. In short, a question would be: How to avoid this?</p>

<p>Thanks in advance for your time.</p>

<docker><docker-compose>
Workflow with docker in the development environment
Mr. Mars
# Workflow with docker in the development environment

(Asked by: username_0 on 2020-03-09)

I have a couple of questions related to the usage of Docker in a development environment. I am going to propose three different scenarios of how I think Docker could be used in a development environment. Let's imagine that we are creating a REST API in Java and Spring Boot. For this, I will need a MySQL database.

1. The first scenario is to have a docker-compose for development with the MySQL container and a production docker-compose with MySQL and the Java application (jar) in another container. To develop I launch the docker-compose-dev.yml to start only the database. The application is launched and debugged using the IDE, for example, IntelliJ Idea. Any changes made to the code, the IDE will recognize and relaunch the application by applying the changes.
2. The second scenario is to have, for both the development and production environment, a docker-compose with the database and application containers. That way, every time I make a change in the code, I have to rebuild the image so that the changes are loaded in the image and the containers are launched again. This scenario may be the most typical and used for development with Docker, but it seems very slow due to the need to rebuild the image every time there is a change.
3. The third scenario consists of a mixture of the previous two. Two docker-compose. The development docker-compose contains both containers, but with mechanisms that allow a live reload of the application, mapping volumes and using, for example, Spring Dev Tools. In this way, the containers are launched and, in case of any change in the files, the application container will detect that there is a change and will be relaunched. For production, a docker-compose would be created simply with both containers, but without the functionality of live reload. This would be the ideal scenario, in my opinion, but I think it is very dependent on the technologies used since not all allow live reload.

The questions are as follows.

* Which of these scenarios is the most typical when using Docker for development?
* Is scenario 1 well raised? That is, dockerize only external services, such as databases, queues, etc. and perform the development and debugging of the application with the IDE without using Docker for it.

The doubts and the scenarios that I raise came up after I raised the problem that scenario 2 has. With each change in the code, having to rebuild the image and start the containers again is a significant waste of time. In short, a question would be: How to avoid this?

Thanks in advance for your time.

**Tags:** docker, docker-compose


---

## 1 answers

### Answer by username_1 on 2020-03-10. Score: 1

We use kubernetes / minikube rather than docker-compose, but its the same problem.
We generally go with option #1 as:

* Development is 99% getting the app right.
* You want to be able to iterate fast/freely with your app.
* You want easy use of your debugger / IDE without inhibition.
* It lets you avoid configuring / managing remote debuggers from within the docker container.
  + If you did this in the container, you'd have to worry about making sure you didn't actually put it in prod as it can be harmful; see below.

For most code changes, we actually just have GitLab-CI set up so that it test-builds/deploys the container/app on check in (on their own branch/space). That way, most developers don't even need to think about the container part unless they're making mods to that area. But, obviously you'd still want them being able to run the MySQL container locally and easily.

### Remote Debugging Info

<https://jaxenter.com/remote-debugging-java-applications-151466.html>

> **Warning: Don’t keep remote debugging JVM arguments ON always, as it has following downsides:**
>
> Remote debugging mode disables several optimizations that JVM does to application to optimize the performance. All those optimizations will be lost.
> Remote debugging opens up a port. It’s a security risk, as anyone who can hit the server can initiate remote debugging


---

