You can download the Docker installer from the Docker website. If you use Brew you can install Docker as a cask with:
brew install --cask docker
Run Docker by using the command line or Docker.app
. The first time you do this there will be additional commands to run.
Check out the list of Postgres versions available in docker. To get the latest one pull it on the command line:
docker pull postgres
After you do this you can run docker images
to see your postgres image or view it in the Docker Desktop GUI.
The Postgres image requires that you supply a root password. You cannot set this in the Docker Desktop GUI and must do so on the command line.
docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
Use the Docker Desktop GUI or the command line with docker ps
to ensure that the container is running.
Next, you can get the IP address of the Postgres database in Docker by running the following command, using the name of your instance.
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' YOUR_CONTAINER_NAME
HOWEVER, in most cases this WILL NOT be the hostname of the database.
When you first ran the container, you provided the root password for the postgres container as an environmental variable. The root user for the database is postgres
.
In the connection screen in Arctype below, we have forwarded the docker port to another local port, 9.8.7.6
and we have determined that the localhost
is the interface which Docker is running on. Finally, we have the postgres
user and the password we supplied to the container at runtime.
Press Test Connection to verify that everything is working and then Save!