Dockerfile para geração de uma máquina docker com o postgres na versão adequada e população do banco através do dump do portal antigo. – README.md

README.md

SPB Database Container

This project allows the creation of a docker container running on Postgresql 8.4 and populated with the provided SPB dump. This container already exposes the port 5432 so you may link it with other docker containers. If you wish to access the database from your host machine you still need to use the -p parameter to forward the port.

Building the image

To build the image you need to provide 2 sql files:

  • db.pgdump: the plain sql from spb database which you can generate with a pg_dump -t table1 -t table2 ... > db.pgdump
  • db.pgdump.globals: the globals from the database which you can generate with a pg_dumpall --globals-only > db.pgdump.globals

Then run:

# docker build . -t <image-name>

Running the image

To run the image you just need to execute:

# docker run -d <image-name>

The -d option will run the container as a daemon

Running the image to access it from the host machine

# docker run -d -p <container-port>:<host-port> <image-name>

Now you can access the database from your host machine on .

Linking the container with other containers

To link the container with other containers, run:

# docker run -d --name <alias> <image-name>

Now to connect this container with other container you just need to run:

# docker run -d --name <alias> <image-name>
# docker run --link <alias>:<alias> <another-image>

After this, your second container will have access to the database through host defined as the environment variable <ALIAS>_PORT_5432_TCP_ADDR and port <ALIAS>_PORT_5432_TCP_PORT.

E.g: if I use the alias db for my database container, on the other container I would provided with DB_PORT_5432_TCP_ADDR and DB_PORT_5432_TCP_PORT environment variables. With this information I could access the database with a simple:

$ psql -h "$DB_PORT_5432_TCP_ADDR" -p "$DB_PORT_5432_TCP_PORT" -U postgres -d spb