In the world of ephemeral services, Docker images provide a great way to have disposable I services on a ‘quick in, quick out’ scenario. With that ease of use, bad practice can creep in. Here we’re discussing some of the ways to optimise production usage of Docker in a single-host scenario.
While it is simple enough to just run Docker from the command line using various switches, you are missing a big time-saving trick. Replacing those command lines with Docker Compose and a YAML Docker config file is a much better way to achieve a consistent outcome. Using Docker Compose also cleans up after itself, removing resources when it is brought down, so it makes complete sense to use it.
Using a single file, you can include an entire software stack defined in one file that can be deployed, version-controlled and consistent. You could use a script but it’s not the ’90s any more. You do, however, need to install the tool to use it. For example, in Ubuntu, it’s as simple as: $ sudo apt install -y docker-compose