Answers
Here are sample answers to the questions of this chapter:
- We have learned how to run an application in a container. We have seen examples written in Node.js, Python, Java, and .NET C#. We have learned how the Dockerfile must look to create an image. Specifically, we have learned how to define the startup command to execute when a container is created from such an image. In the case of a Java application, this could be as follows:
CMD java -jar /app/my-app.jar
For a Node.js application, it could be as follows:
CMD node index.js
To run the unit tests for the application, we just have to use a different startup command.
- We strongly advise against shipping test code to a production environment. Tests bloat the Docker image, which has several negative side effects, such as the following:
- Providing a bigger surface for hacker attacks
- Longer startup times for the container since it takes longer to load an image from storage into the memory of the container...