Simple Migration for Postgres
Imagine the following scenario: You want to execute a sql file (for example for migrations) on a running postgres container.
Internally this image uses the really useful shmig tool by naquad. You can specify the following environment variables to configure it
DB_USER=postgres # the user of the database DB_PASSWORD=s3cr3tPw # password to the database DB_NAME=postgres # the database name DB_HOST=postgres_host # the host of the database, usually the name of the db container SLEEP=n # sleep n seconds before executing
You can set these either through the
-e switches of
docker run or with the supplied
Additionally, you have to link the container to a running postgres container. The
DB_HOST variable is usually corresponds to the name of the linked container.
Finally, the image expects you to mount a volume to
/migrations to store migrations.
CMD of this image is
up. If you want to run other commands, append the following options to your
docker run or
create my-migrationcreates a new migration with the name
uprun your migrations
downrevert your migrations
The complete documentation of shmig is available at