1. Running My First Docker Container
Activity 1.01: Pulling and Running the PostgreSQL Container Image from Docker Hub
Solution:
- To start the Postgres Docker container, first determine what environment variables are required to set the default username and password credentials for the database. Reading through the official Docker Hub page, you can see that you have configuration options for the
POSTGRES_USER
andPOSTGRES_PASSWORD
environment variables. Pass the environment variables using the-e
flag. The final command to start our Postgres Docker container will be as follows:docker run -itd -e "POSTGRES_USER=panoramic" -e "POSTGRES_PASSWORD=trekking" postgres:12
Running this command will start the container.
- Execute the
docker ps
command to verify that it is running and healthy:$ docker ps
The command should return output like the following:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS ...