Docker advanced use cases
While using Docker and its CLI, there are a lot of things we will need to take care of in terms of the life cycle of the container, build process, volumes, and networking. Some of those things you can automate by using other tools, but it’s still useful to know what’s going on underneath.
Running public images
A lot of public images you can find on Docker Hub (https://hub.docker.com) have initialization scripts available that take configuration from environment variables or the mounted files to a predefined directory.
The most commonly used image that uses both techniques is images with databases. Let’s look for an official Docker PostgreSQL image. You can find the one we’ll be using here: https://hub.docker.com/_/postgres.
To run the official PostgreSQL Docker image, you can use the following command:
admin@myhome:~$ docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
In this command...