docker compose up -d -> Additional property environnement is not allowed. Why? - docker-compose

I tried to pass the command
docker compose up -d
but I've got
Additional property environnement is not allowed from Debian
here is my yaml file
version: "3"
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environnement:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
Can you help?

Related

How to create two postgres docker containers from docker compose file , one for development and one for testing?

So for example this is my docker-compose.yml file:
version: "3.7"
services:
postgres:
container_name: mydevdb
image: postgres:13
restart: always
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- postgres:/var/lib/postgresql/data
ports:
- "5432:5432"
volumes:
postgres:
And I want to have an image for development and another for testing with different (container name, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB and port)
I want the best approach for that. Thanks.
You just have to give the services different names. (and maybe different port exposures, depending on how you want to use them)
version: "3.7"
services:
postgres-dev:
container_name: mydevdb
image: postgres:13
restart: always
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- postgres-dev:/var/lib/postgresql/data
ports:
- "5432:5432"
postgres-test:
container_name: mytestdb
image: postgres:13
restart: always
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- postgres-test:/var/lib/postgresql/data
ports:
- "5432:5432"
volumes:
postgres-dev:
postgres-test:

ERROR: Named volume "postgres:/data/postgres:rw" is used in service "postgres" but no declaration was found in the volumes section

i am trying to build micro service project.
and i am getting this error when i am trying to run my docker_compose file:
ERROR: Named volume "postgres:/data/postgres:rw" is used in service "postgres" but no declaration was found in the volumes section.
this is my docker_compose file :
services:
postgres:
container_name: postgres
image: postgres
environment:
POSTGRES_USER: amigoscode
POSTGRES_PASSWORD: password
PGDATA: /data/postgres
volumes:
- postgres:/data/postgres
ports:
- "5432:5432"
networks:
- postgres
restart: unless-stopped
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4#pgadmin.org}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- pgadmin:/var/lib/pgadmin
ports:
- "5050:80"
networks:
- postgres
restart: unless-stopped
any hint will be appreciated.
You are missing the relative path, this would work. Either use a relative path or a fixed one!
services:
postgres:
container_name: postgres
image: postgres
environment:
POSTGRES_USER: amigoscode
POSTGRES_PASSWORD: password
PGDATA: /data/postgres
volumes:
- ./postgres:/data/postgres
ports:
- "5432:5432"
networks:
- postgres
restart: unless-stopped
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4#pgadmin.org}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- ./pgadmin:/var/lib/pgadmin
ports:
- "5050:80"
networks:
- postgres
restart: unless-stopped

How to get docker compose to create pg DB if not found

I am using NestJS with TypeOrm and PostGres to define the Database.
I would like to have docker-compose create the DB if it does not exist in the container.
docker-compose.yaml
version: '3.9'
services:
backend:
build: .
ports:
- 8000:3000
volumes:
- .:/app
depends_on:
- db
db:
image: postgres:14.1
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
volumes:
- ./postgres-data:/var/lib/postgresql/data
ports:
- 33066:5432
pgadmin:
container_name: pgadmin4_container_shibari
image: dpage/pgadmin4
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: admin#admin.com
PGADMIN_DEFAULT_PASSWORD: root
ports:
- '5050:80'
redis:
image: redis
ports:
- 6379:6379

Docker Compose MariaDB with Adminer

I was trying to use adminer as my gui to manage my database. For that, in my docker-compose file I defined a Username, a Password and the Database. But everytime I tried to access the database with the correct data. I got the following error:
And my docker-compose code is the following:
version: "3.8"
services:
mariadb:
image: mariadb:latest
container_name: mariadb
restart: always
environment:
MYSQL_USER: adminer
MYSQL_PASSWORD: adminer
MYSQL_DATABASE: noinch
ports:
- 5555:3306
volumes:
- db_data:/var/lib/mysql
adminer:
image: adminer:latest
container_name: adminer
restart: always
ports:
- 7777:8080
volumes:
db_data:
Have a nice day!
You must tell the Adminer the environment variables.
environment:
ADMINER_DEFAULT_SERVER: mariadb
version: "3.8"
services:
mariadb:
image: mariadb:latest
container_name: mariadb
restart: always
environment:
MYSQL_USER: adminer
MYSQL_PASSWORD: adminer
MYSQL_DATABASE: noinch
ports:
- 5555:3306
volumes:
- db_data:/var/lib/mysql
adminer:
image: adminer:latest
container_name: adminer
environment:
ADMINER_DEFAULT_SERVER: mariadb
restart: always
ports:
- 7777:8080
volumes:
db_data:

Error while running compose up. YAML linter showing no errors

I keep getting a service 'image' error when running docker-compose up for my yml file.
I researched online and it seems like it was mostly some formatting error.
I have run my yml through a YAML linter and there are no errors.
version: '3.5'
services:
server:
image: postgrest/postgrest
ports:
- "3000:3000"
links:
- db:db
environment:
PGRST_DB_URI: postgres://app_user:password#db:5432/app_db
PGRST_DB_SCHEMA: public
PGRST_DB_ANON_ROLE: app_user
depends_on:
- db
db:
image: postgres
ports:
- "5432:5432"
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
PGDATA: /data/postgres
volumes:
- postgres:/data/postgres
networks:
- postgres
restart: unless-stopped
pgadmin:
container_name: pgadmin_container
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4#pgadmin.org}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
volumes :
- pgadmin:/root/.pgadmin
ports:
-"${PGADMIN_PORT:-5050}:80"
networks:
- postgres
restart: unless-stopped
networks:
postgres:
driver: bridge
volumes:
postgres:
pgadmin:
swagger:
image: swaggerapi/swagger-ui
ports:
- "8080:8080"
expose:
- "8080"
environment:
API_URL: http://localhost:3000/
Expected would be the images get downloaded and containers get started up
Error is:
ERROR: In file '.\docker-compose.yml', service 'image' must be a mapping not a string.
This issue happens because of indentation.
docker-compose deals with image like a service because of wrong indentation.
I modified your file and start configured containers successfully:
version: "3.5"
services:
server:
image: postgrest/postgrest
ports:
- "3000:3000"
links:
- db:db
environment:
PGRST_DB_URI: postgres://app_user:password#db:5432/app_db
PGRST_DB_SCHEMA: public
PGRST_DB_ANON_ROLE: app_user
depends_on:
- db
db:
image: postgres
ports:
- "5432:5432"
environment:
POSTGRES_USER: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4#pgadmin.org}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
PGDATA: /data/postgres
volumes:
- postgres:/data/postgres
networks:
- postgres
restart: unless-stopped
pgadmin:
container_name: pgadmin_container
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4#pgadmin.org}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
volumes:
- pgadmin:/root/.pgadmin
ports:
- "${PGADMIN_PORT:-5050}:80"
networks:
- postgres
restart: unless-stopped
swagger:
image: swaggerapi/swagger-ui
ports:
- "8080:8080"
expose:
- "8080"
environment:
API_URL: http://localhost:3000/
networks:
postgres:
driver: bridge
volumes:
pgadmin:
postgres: