Skip to content

Instantly share code, notes, and snippets.

@Klerith
Last active May 18, 2024 23:33
Show Gist options
  • Save Klerith/8cfc637868212cfb888333ecaa6080e1 to your computer and use it in GitHub Desktop.
Save Klerith/8cfc637868212cfb888333ecaa6080e1 to your computer and use it in GitHub Desktop.
Tarea sobre PGAdmin y Postgres

Docker Hub images

Postgres

pgAdmin

1. Crear un volumen para almacenar la información de la base de datos

docker COMANDO CREAR postgres-db

2. Montar la imagen de postgres así

OJO: No hay puerto publicado -p, lo que hará imposible acceder a la base de datos con TablePlus

docker container run \
-d \
--name postgres-db \
-e POSTGRES_PASSWORD=123456 \
-v postgres-db:/PATH/DE/LA/BASE/DE/DATOS \
postgres:15.1

Powershell

docker container run `
-d `
--name postgres-db `
-e POSTGRES_PASSWORD=123456 `
-v postgres-db:/PATH/DE/LA/BASE/DE/DATOS `
postgres:15.1

3. Tomar pgAdmin de aquí

docker container run \
--name pgAdmin \
-e PGADMIN_DEFAULT_PASSWORD=123456 \
-e PGADMIN_DEFAULT_EMAIL=superman@google.com \
-dp 8080:80 \
dpage/pgadmin4:6.17

Powershell

docker container run `
--name pgAdmin `
-e PGADMIN_DEFAULT_PASSWORD=123456 `
-e PGADMIN_DEFAULT_EMAIL=superman@google.com `
-dp 8080:80 `
dpage/pgadmin4:6.17

4. Ingresar a la web con las credenciales de superman

http://localhost:8080/

5. Intentar crear la conexión a la base de datos

  1. Click en Servers
  2. Click en Register > Server
  3. Colocar el nombre de: "SuperHeroesDB" (el nombre no importa)
  4. Ir a la pestaña de connection
  5. Colocar el hostname "postgres-db" (el mismo nombre que le dimos al contenedor)
  6. Username es "postgres" y el password: 123456
  7. Probar la conexión

6. Ohhh no!, no vemos la base de datos, se nos olvidó la red

7. Crear la red

docker network ALGO PARA CREAR postgres-net

8. Asignar ambos contenedores a la red

docker container ALGO PARA LISTAR LOS CONTENEDORES

9. Conectar ambos contenedores

docker network connect postgres-net ID del contenedor 1

docker network connect postgres-net ID del contenedor 2

10. Intentar el paso 4. de nuevo.

Si logra establecer la conexión, todo está correcto, proceder a crear una base de datos, schemas, tablas, insertar registros, lo que sea.

11. Saltar de felicidad

happy

@AntGovea
Copy link

image

@DiegoGutierrezP
Copy link

Felicidad!
image

@rperdomo24
Copy link

image
Nice!

@farney9
Copy link

farney9 commented May 7, 2024

Done !! 😃 🕺🏼

image

@yuber83
Copy link

yuber83 commented May 7, 2024

image
completado, muy facil

@SaraRoLa
Copy link

SaraRoLa commented May 8, 2024

Completado!
image

@DaniDotExe
Copy link

GG

@LuisJosueSantanaPerez
Copy link

Completado!!!.

@ivan2214
Copy link

Completado !!!!
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment