docker-compose.yml services.php must be a mapping - docker-compose

I've seen this same error in dozens of questions. All say check the indentation.
I can't see any errors with the indentation.
When I try to run I get this error Services.php must be a mapping what could cause this error?
version: '3'
services:
php:
image: may/web-php:$PHP_TAG
container_name: "${PROJECT_NAME}_php"
environment:
DB_HOST: $HOST
DB_USER: $USER
DB_PASSWORD: $PASSWORD
DB_NAME: $NAME
DB_DRIVER: $DRIVER
TEST_PASSWORD: ${TEST_PASSWORD}
ENVIRONMENT: ${ENVIRONMENT}
volumes:
- ../var/www/html:cached
# Persistent data volumes.
volumes:
database-volume:

Related

mysql docker container does not start on windows. erro: mysql exited with code 1. Can somone help me?

this is my docker-compose code
Could you provide more information about the error?
Just going off of what you provided, I would try using something like this:
version: '3.3'
services:
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: 'manage_car'
MYSQL_USER: 'manage_car'
MYSQL_PASSWORD: 'manage_car'
MYSQL_ROOT_PASSWORD: 'manage_car'
ports:
- '3306:3306'
expose:
- '3306'
volumes:
- my-db:/var/lib/mysql
volumes:
my-db:
There's also a good tutorial for running mysql with Docker Compose here

Cant login with docker compose to Postgres via pgadmin

I have the following docker-compose:
version: '3.1'
services:
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: postgres
volumes:
- postgres:/pgdata
ports:
- "5432:5432"
pdadmin:
image: dpage/pgadmin4
restart: always
ports:
- "8080:80"
environment:
PGADMIN_DEFAULT_EMAIL: example#gmail.com
PGADMIN_DEFAULT_PASSWORD: example
volumes:
postgres:
when I try to login to postgres via pgadmin i am getting the error: password authentication failed for user "postgres"
I am trying with user postgres and password postgres.
I also tryied to add explisit POSTGRES_USER to the env with no success.
How can I login to my postgres database?
Thanks
you're very close:
version: '3.1'
services:
db:
image: postgres
restart: always
environment:
POSTGRES_USER: postgres # <-- add this
POSTGRES_PASSWORD: postgres
volumes:
- postgres:/pgdata
ports:
- "5432:5432"
pdadmin:
image: dpage/pgadmin4
restart: always
ports:
- "8080:80"
environment:
PGADMIN_DEFAULT_EMAIL: example#gmail.com
PGADMIN_DEFAULT_PASSWORD: example
depends_on: # <-- add this
- db # <-- add this
links: # <-- add this
- db # <-- add this
volumes:
postgres:
Then connect to pgadmin http://localhost:8080
when you want to add new server you need to add the IP of the container
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container_id>
That it !
try it
PGADMIN_DEFAULT_PASSWORD: Example123
Use a mixture of upper and lower case letters and numerics

I cannot connect from adminer to postgresql

I try to up postgresql and adminer via docker container. But from adminer I cannot enter to postgresql with password and user I whote.
SQLSTATE[08006] [7] FATAL: password authentication failed for user "root"
I tried all.
version: '3'
services:
web:
build: .
environment:
- APACHE_RUN_USER=www-data
volumes:
- ./blog:/var/www/html/
ports:
- 8080:80
working_dir: /var/www/html/
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: kisphp
POSTGRES_USER: root
POSTGRES_DB: kisphp
ports:
- "5432:5432"
volumes:
- ./postgres:/var/lib/postgresql/data
adminer:
image: adminer
restart: always
ports:
- "6080:8080"
This docker-compose configuration works well.
Try recreating it from scratch:
Delete ./postgres folder
docker-compose stop
docker-compose down
docker-compose up -d

Docker compose MySQL-volumes invalid invalid specification

I am using service 3 and below is mycode,
I tried to add the var- COMPOSE_CONVERT_WINDOWS_PATHS: 1 in environment
it still get the error:
ERROR: for db-on-docker-ms_mysql-dev_1 Cannot create container for service mysql-dev: invalid volume specification: '/c/Dockerfile/db-on-docker-ms:/var/lib/mysql under volumes:rw'
version: '3'
services:
mysql-dev:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: blogapp
ports:
- "3308:3306"
volumes:
- /c/Dockerfile/db-on-docker-ms:/var/lib/mysql
My Docker Version: 18.09.2
I think you either need set COMPOSE_CONVERT_WINDOWS_PATHS environment variable from your command line
$ export COMPOSE_CONVERT_WINDOWS_PATHS=1
Then change the volumes configuration
version: '3'
services:
mysql-dev:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: blogapp
ports:
- "3308:3306"
volumes:
- c:\Dockerfile\db-on-docker-ms:/var/lib/mysql
Run docker compose
$ docker-compose up
Or you can attempt to set the volumes like this
version: '3'
services:
mysql-dev:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: blogapp
ports:
- "3308:3306"
volumes:
- //c/Dockerfile/db-on-docker-ms:/var/lib/mysql
And run docker compose
$ docker-compose up
Thanks for Misantorp's ans first!
I finally figure out how to do it in windows container
the volumes path should be:
volumes:
- C:\Dockerfile\db-on-docker-ms:/var/lib/mysql
run the command in powershell:
COMPOSE_CONVERT_WINDOWS_PATHS=0
then run:
docker-compose up

Keycloak is not saving data in PostgreSQL in docker

I am trying to run keycloak in docker and to save its data in PostgreSQl.
But nothing is being saved.
this is the docker-compose.yml file:
version: '2'
services:
db:
build: "./Main Database Backup"
environment:
POSTGRES_DB: ${DB_POSTGRES_APP_DATABASE}
POSTGRES_USER: ${DB_POSTGRES_APP_USER}
POSTGRES_PASSWORD: ${DB_POSTGRES_APP_PASSW}
PGDATA: /var/lib/postgresql/data/pgdata
ports:
- "5432:5432"
restart: unless-stopped
keycloak-postgres:
image: postgres:10-alpine
environment:
POSTGRES_DB: ${KEYCLOAK_DATABASE}
POSTGRES_PASSWORD: ${KEYCLOAK_DATABASE_PASSW}
POSTGRES_USER: ${KEYCLOAK_DATABASE_USER}
PGDATA: /var/lib/postgresql/data/pgdata
restart: unless-stopped
keycloak:
build: "./Keycloak Realm Export"
depends_on:
- keycloak-postgres
environment:
KEYCLOAK_USER: ${KEYCLOAK_USER}
KEYCLOAK_PASSWORD: ${KEYCLOAK_PASSWORD}
POSTGRES_USER: ${KEYCLOAK_DATABASE_USER}
POSTGRES_PASSWORD: ${KEYCLOAK_DATABASE_PASSW}
POSTGRES_PORT_5432_TCP_ADDR: keycloak-postgres
ports:
- "8080:8080"
Dockerfile in for keycloak
FROM jboss/keycloak:3.4.3.Final
WORKDIR /opt/jboss/keycloak
COPY realm-export.json initial_data.json
# RUN ./bin/standalone.sh -Dkeycloak.migration.action=import -Dkeycloak.migration.provider=singleFile -Dkeycloak.migration.file=initial_data.json -Dkeycloak.migration.strategy=OVERWRITE_EXISTING
RUN ./bin/add-user-keycloak.sh -r master -u admin -p password
ENTRYPOINT [ "/opt/jboss/docker-entrypoint.sh" ]
CMD ["-b", "0.0.0.0", "-Dkeycloak.import=/opt/jboss/keycloak/initial_data.json"]
That db is the main database which is for my API and its working correctly.
While the keycloak-postgres is the database for keycloak and its not saving any data.
Also I have created a database in that server with the same name as ${KEYCLOAK_DATABASE} and I have created a user and gave all privileges to that server, so it wont be a permission error.
And I have provided all the environment variables correctly.
Also regarding to commented code in keycloak Dockerfile, I'm trying to import a realm which is not working.
When I'm commenting that POSTGRES_PORT_5432_TCP_ADDR in docker-compose.yml its throwing this error:
2018-08-31T08:22:05.251344638Z 08:22:05,250 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
2018-08-31T08:22:05.251375320Z ("subsystem" => "datasources"),
2018-08-31T08:22:05.251383320Z ("data-source" => "KeycloakDS")
2018-08-31T08:22:05.251402169Z ]) - failure description: "WFLYCTL0211: Cannot resolve expression 'jdbc:postgresql://${env.POSTGRES_PORT_5432_TCP_ADDR}:${env.POSTGRES_PORT_5432_TCP_PORT:5432}/${env.POSTGRES_DATABASE:keycloak}'"
This isn't Keycloak related, it's more Docker container related (and postgres). Each time you stop a container you going to loose your data.
What you need to use is Volumes ... meaning. Map a driver on your PC to the docker container. Such that each time the container starts again it uses this drive therefore able to retain data. You need something along the lines of:
version: '2'
volumes:
postgres_data:
driver: local
services:
db:
build: "./Main Database Backup"
environment:
POSTGRES_DB: ${DB_POSTGRES_APP_DATABASE}
POSTGRES_USER: ${DB_POSTGRES_APP_USER}
POSTGRES_PASSWORD: ${DB_POSTGRES_APP_PASSW}
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- postgres_data:/var/lib/postgresql/data
- ./data:/docker-entrypoint-initdb.d
ports:
- "5432:5432"
restart: unless-stopped