Let’s say that it’s 2019 and for some odd reason you need to setup a PHP dev env
First, let’s start a postgres service.
This docker container has to have a name. my-postgres
in this case. It will be used
To connect a client to postgres, we can run
--link my-postgres
will make my-postgres
DNS points to the IP of my-postgres
container.
Then we say to psql
connect to my-postgres
host.
Now we can run the php
container.
First, go to your working dir
See that we are connecting the pg_connect
to mypostgres
host.
Now you can connect to http://localhost:8000
and see your awesome app.
For PHP reaons, PHP will not stop with ctrl+c
nor ctrl+d
To stop this container, we need to run docker kill my-php
Conexao Postgres utilizndo pHP
Insere um dado em uma tabela