### Setup PostgreSQL 10 and pgAdmin 4 Containers with Docker Source: https://context7.com/diegomarinho/postgres-pgadmin4-docker/llms.txt This script automates the setup of PostgreSQL 10 and pgAdmin 4 containers. It creates necessary Docker volumes for data persistence, a bridge network for communication, and then launches both the PostgreSQL and pgAdmin 4 containers with specified environment variables and port mappings. Access pgAdmin via http://localhost:5050. ```bash # Run the PostgreSQL setup script sudo sh setup-postgres.sh # The script performs the following operations: # 1. Creates Docker volumes for persistent storage docker volume create --driver local --name=pgvolume docker volume create --driver local --name=pga4volume # 2. Creates a bridge network for container communication docker network create --driver bridge pgnetwork # 3. Starts PostgreSQL 10 container docker run --publish 5432:5432 \ --volume=pgvolume:/pgdata \ --env-file=pg-env.list \ --name="postgres" \ --hostname="postgres" \ --network="pgnetwork" \ --detach \ crunchydata/crunchy-postgres:centos7-10.5-2.1.0 # 4. Starts pgAdmin 4 container docker run --publish 5050:5050 \ --volume=pga4volume:/var/lib/pgadmin \ --env-file=pgadmin-env.list \ --name="pgadmin4" \ --hostname="pgadmin4" \ --network="pgnetwork" \ --detach \ crunchydata/crunchy-pgadmin4:centos7-10.5-2.1.0 # Access pgAdmin at http://localhost:5050/ # Login: sas@sulamerica.com.br / sas123456 # Add server with hostname: postgres, user: sas, password: sas123 ``` -------------------------------- ### Manage PostgreSQL and pgAdmin Container Lifecycle Source: https://context7.com/diegomarinho/postgres-pgadmin4-docker/llms.txt This section provides essential Docker commands for managing the lifecycle of PostgreSQL and pgAdmin containers after their initial setup. It covers common operations such as starting, stopping, restarting, and viewing the status of these containers, ensuring effective control over the database environment. ```bash # Example commands for managing PostgreSQL and pgAdmin containers: # Stop PostgreSQL container docker stop postgres # Start PostgreSQL container docker start postgres # Restart PostgreSQL container docker restart postgres # Stop pgAdmin 4 container docker stop pgadmin4 # Start pgAdmin 4 container docker start pgadmin4 # Restart pgAdmin 4 container docker restart pgadmin4 # View status of all containers docker ps -a # View logs for PostgreSQL container docker logs postgres # View logs for pgAdmin 4 container docker logs pgadmin4 ``` -------------------------------- ### Configure PostgreSQL Container Environment Variables Source: https://context7.com/diegomarinho/postgres-pgadmin4-docker/llms.txt This file defines environment variables for the PostgreSQL container, including database credentials, user accounts, and connection settings. These variables are loaded using an '--env-file' argument when running the Docker container, allowing for easy customization of the database environment. ```bash # postgres/pg-env.list PG_MODE=primary PG_PRIMARY_USER=sas PG_PRIMARY_PASSWORD=sas123 PG_DATABASE=sasdb PG_USER=sas PG_PASSWORD=sas123 PG_ROOT_PASSWORD=sas123456 PG_PRIMARY_PORT=5432 # Connect to PostgreSQL from command line psql -h localhost -p 5432 -U sas -d sasdb # Password: sas123 ``` -------------------------------- ### Configure pgAdmin 4 Container Environment Variables Source: https://context7.com/diegomarinho/postgres-pgadmin4-docker/llms.txt This file specifies environment variables for the pgAdmin 4 container, such as administrator credentials and the server port. These settings are crucial for accessing and managing the PostgreSQL database through the pgAdmin web interface. The web interface is accessible at http://localhost:5050. ```bash # postgres/pgadmin-env.list PGADMIN_SETUP_EMAIL=sas@sulamerica.com.br PGADMIN_SETUP_PASSWORD=sas123456 SERVER_PORT=5050 # Access pgAdmin web interface curl -I http://localhost:5050/ # HTTP/1.1 200 OK ``` -------------------------------- ### Deploy Redis 4.0.8 with Docker Swarm Source: https://context7.com/diegomarinho/postgres-pgadmin4-docker/llms.txt This script deploys Redis 4.0.8 using Docker Swarm mode, ensuring high availability and scalability. It initializes the Swarm if necessary, creates a directory for persistent data storage, and then deploys the Redis service using a provided Docker Compose file. The script also includes verification steps to confirm the Redis container is running. ```bash # Start Redis with Docker Swarm sudo sh start-redis.sh # The script performs: # 1. Initialize Docker Swarm (if not already initialized) docker swarm init # 2. Create data directory for persistence export STACK_NAME='test' mkdir -p ~/data/${STACK_NAME}/redis # 3. Deploy Redis stack sudo STACK_NAME=${STACK_NAME} docker stack deploy --compose-file redis/compose.yml ${STACK_NAME} # Verify Redis is running docker ps -a # CONTAINER ID IMAGE COMMAND STATUS PORTS NAMES # a3adecb5c143 redis:4.0.8-alpine "docker-entrypoint.s…" Up 2 seconds 6379/tcp test_redis.1.xxx # Connect to Redis CLI docker exec -it redis-cli # 127.0.0.1:6379> PING # PONG # 127.0.0.1:6379> SET mykey "Hello" # OK # 127.0.0.1:6379> GET mykey # "Hello" ``` -------------------------------- ### Configure Redis Service with Docker Compose for Swarm Source: https://context7.com/diegomarinho/postgres-pgadmin4-docker/llms.txt This Docker Compose file defines the Redis service for deployment within a Docker Swarm. It configures an overlay network for inter-service communication, maps the Redis port, and sets up persistent volume storage using a host directory. The 'deploy' section specifies the number of replicas for the Redis service. ```yaml # redis/compose.yml version: "3.4" networks: servicenet: driver: overlay ipam: config: - subnet: 10.0.9.0/24 services: redis: image: redis:4.0.8-alpine networks: - servicenet ports: - target: 6379 published: 6379 protocol: tcp mode: ingress volumes: - "~/data/${STACK_NAME}/redis:/data" deploy: replicas: 1 # Deploy manually with: export STACK_NAME='test' docker stack deploy --compose-file redis/compose.yml ${STACK_NAME} ``` -------------------------------- ### Stop and Remove Redis Docker Swarm Stack Source: https://context7.com/diegomarinho/postgres-pgadmin4-docker/llms.txt This script is used to gracefully stop and remove the Redis Docker Swarm stack. It executes the 'docker stack rm' command, which removes all services, containers, and networks associated with the specified stack name. This is useful for cleaning up resources after development or testing. ```bash # Stop and remove Redis stack sudo sh stop-redis.sh # The script executes: export STACK_NAME='test' docker stack rm ${STACK_NAME} # Verify stack is removed docker stack ls # NAME SERVICES ORCHESTRATOR ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.