Some best practices of docker and microservices
This helps in understanding some tips and best practices while building containers with Docker.
Some of the Best practices are documented in the link:
- Run only one process per container
- Minimize the number of layers
- Sort arguments which are passed to scripts or commands.
- Why to run apache in foreground:Run Apache in foreground. We need to run the apache process in the foreground, since our container will stop when the process specified in the docker run command stops. We can do this with a flag -D when starting the apache2 process:
/usr/sbin/apache2ctl -D FOREGROUND
- Permanently running a container: While the sections above explained how to run a container when configuring it, for a production setup, you should not manually start and babysit containers. Instead, create a systemd unit file to make systemd keep that container running.
- Systemd to manage the lifecycle of your Docker containers