- It is preferable to use Dockerfile to create an image.
- Using Dockerfile is the only way you can be sure of reproducing the same image every time.
- Use a Layered approach, but keep in mind that Docker imposes limits on the number of layers an image can have. To minimize layer, you can combine commands in Dockerfile.
- Use .dockerignore file to avoid any extra files/directories when building images.
- Avoid very large images because they will take too long to download/upload..
- Use Data volume to share data between containers.
- Do not store temporary Docker images in the Docker registry. It’s best to save the images and tar file to share with other developers. We can use standard Docker repo but we need to make sure they get deleted using an automated process.
- If you are using multiple containers for your application, for example Database, Some Service and Web App Container, it’s better to user Docker Compose so that all containers can be managed together like starting, stopping etc.