Reputation: 135
I'm having a problem with this.
Idea: I want to execute a sh file at the end of my Docker execution. The problem this:
sh file
source api/.env
sudo docker exec -it postgres_nuevo env PGPASSWORD="$DB_PASSWORD" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME"
and throw me this error: " to address: Try againtranslate host name "postgres_nuevo
I don't know what I'm doing wrong. The env variables are fine, I tested with a echo and hardcoded them it works. The problem is when you use .env vars.
I don't know if can help but here is my yml.
version: '3'
services:
api:
build:
context: .
dockerfile: Dockerfile
args:
GIT_BRANCH: ${GIT_BRANCH}
GIT_USER: ${GIT_USER}
GIT_PASS: ${GIT_PASS}
GIT_REPO: ${GIT_REPO}
container_name: api
networks:
- proxy-network
- default
- datalaketdf
ports:
- "${API_PORT}:8000"
volumes:
- .:/app
depends_on:
- postgres_nuevo
- adminer
command: >
sh -c "
python manage.py makemigrations;
python manage.py migrate;
python manage.py makemigrations datawarehouseApp;
python manage.py migrate datawarehouseApp;
python manage.py runserver 0.0.0.0:8000
"
restart: always
postgres_nuevo:
image: postgres:14.1-alpine
restart: always
networks:
- proxy-network
- datalaketdf
container_name: postgres_nuevo
environment:
- POSTGRES_USER=${API_POSTGRES_USER}
- POSTGRES_PASSWORD=${API_POSTGRES_PASSWORD}
- POSTGRES_DB=${API_POSTGRES_DB}
volumes:
- db:/var/lib/postgresql/data
- ./dumps:/dumps:rw
- ${RUTA_BACKUPS_DUMPS_LOCAL}:/backups:rw
ports:
- "${POSTGRES_PORT}:5432"
user: postgres
adminer:
image: adminer
restart: always
container_name: adminer
networks:
- proxy-network
- datalaketdf
ports:
- ${ADMINER_PORT}:8080
depends_on:
- postgres_nuevo
volumes:
db:
driver: local
networks:
proxy-network:
external: true
datalaketdf:
external: true
Thanks
Upvotes: 0
Views: 21