Note that the image name is dpage/pgadmin4 and that we must specify a couple of environment variables to make it work. Then we read the instructions for running the image. Time: Yay! The data is still there! □ pgAdmin container Which should return the number of records in the table SELECT count(1) FROM yellow_taxi_data Open a terminal and type pgcli -h localhost -p 5432 -u root -d ny_taxiĮnter the database password ("root") when prompted and then, on pgcli, query the table with SELECT count(1) FROM yellow_taxi_data Since we tinkered (ahem, destroyed) with the original Postgres container, let's check if we can still access the inserted data. □ Confirm the data is still there using pgcli If the docker runcommand above was successful, your terminal will be locked and show the "database system is ready to accept connections" message. The value of the name parameter is the network name we are giving to the Postgres container ( pg-database), which we will use in pgAdmin to connect to it. The value of the network parameter is the name we gave to the newly created Docker network, i.e., pg-network. Note that we passed one network and one name parameter. v $(pwd)/ny_taxi_postgres_data:/var/lib/postgresql/data \ On a terminal window type docker run -it \ Now, we need to create a new Postgres container, specifying that it should run on the newly created network. So far, we've created a Docker network and removed the old Postgres container. Where CONTAINER NAME is the name of the Postgres container, which can be found in the docker ps return table above ( blissful_bose in our case). Replacing with the ID shown in the table above (2e3295311dfe in our case).Īfter the container stops, we need to remove it with docker rm / Which will return a table similar to the one below if the container with Postgres is still running CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESĢe3295311dfe postgres:13 "docker-entrypoint.s…" 10 days ago Up 10 days 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp blissful_bose Then, check if the container is still running with docker ps In the terminal running pgcli (from our previous post), type exit and hit Enter to exit pgcli. Let's create a network called pg-network by typing in a terminal window the following command docker network create pg-network □ Stop and remove the Postgres containerīefore we continue, we need to stop the Postgres Docker container if it is still running. This is accomplished by creating a Docker network and adding the containers. These containers are isolated, but we would like them to be able to see each other. We are going to have two containers that we want to use simultaneously.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |