Docker Compose Solr authentication: No authentication configured - docker

I am having issues adding auth to Solr in a Docker container. I have tried copying the security.json file to the Solr container's $SOLR_HOME folder. But it's returning a response at http://localhost:8983/solr/admin/authentication:
{
"responseHeader":{
"status":0,
"QTime":0},
"errorMessages":["No authentication configured"]}
security.json:
{
"authentication":{
"blockUnknown": true,
"class":"solr.BasicAuthPlugin",
"credentials":{"solr":"IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0= Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="},
"realm":"My Solr users",
"forwardCredentials": false
},
"authorization":{
"class":"solr.RuleBasedAuthorizationPlugin",
"permissions":[{"name":"security-edit",
"role":"admin"}],
"user-role":{"solr":"admin"}
}}
I'm copying the file in the docker-compose.yml in the volume:
version: "3"
services:
index:
image: solr:8.11.1
ports:
- "8983:8983"
volumes:
- data:/var/solr
- ./security/security.json:/opt/solr-8.11.1/server/solr/security.json
command:
- solr-precreate
- archive_poc_core
volumes:
data:
When I go into the container and check if the file is there with the settings, I can find it. So I don't think that's the problem. I think that the file is copied after solr is started but not sure how to get the security file prior on the container or what the correct way of doing it should be.
Any help, guidance or advice would be appreciated.
Guides I looked at:
https://solr.apache.org/guide/8_1/basic-authentication-plugin.html#enable-basic-authentication
https://solr.apache.org/guide/8_11/authentication-and-authorization-plugins.html#using-security-json-with-solr

I managed to get this working with help from a colleague of mine. We ended up using Zookeeper for managing the Apache side of things.
docker-compose.yml
version: "3"
services:
solr1:
build:
context: .
dockerfile: solr.Dockerfile
container_name: solr1
ports:
- "8983:8983"
volumes:
- data:/var/solr
environment:
- ZK_HOST=zoo1:2181
depends_on:
- zoo1
tty: true
stdin_open: true
zoo1:
tty: true
image: zookeeper:3.6.2
container_name: zoo1
restart: always
hostname: zoo1
ports:
- 2181:2181
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=0.0.0.0:2888:3888;2181
volumes:
data:
solr.Dockerfile:
It copies over the files I needed like the security.json and solr-security.sh. It also adds in the entrypoint when building.
FROM solr:8.11.1
COPY security/security.json security.json
COPY scripts/solr-security.sh /usr/bin/solr-security.sh
ENTRYPOINT ["/usr/bin/solr-security.sh"]
solr-security.sh:
This executes the authentication for Solr via Zookeeper, you can find out more here https://solr.apache.org/guide/8_11/authentication-and-authorization-plugins.html#in-solrcloud-mode
Then starts up the default entrypoint for Solr after the authentication has been done.
#!/bin/bash
solr zk cp /opt/solr-8.11.1/security.json zk:security.json -z zoo1:2181
exec /opt/docker-solr/scripts/docker-entrypoint.sh "$#"
Everything worked as expected when browsing to Solr, it showed the login screen. I hope this helps someone else who was trying to resolve this.

Related

Multi Container Connection in docker

I have built a CRUD application using spring-boot and MySQL, MySQL is in docker and I am able to connect from local and my application is working. But when I tried to deploy the Spring-boot application in docker now it is not able to connect to Docker MySQL.
## Spring application.properties
server.port=8001
# MySQL Props
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto = create
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:9001}/${MYSQL_DATABASE:test-db}
spring.datasource.username=${MYSQL_USER:admin}
spring.datasource.password=${MYSQL_PASSWORD:nimda}
##Dockerfile
FROM openjdk:11
RUN apt-get update
ADD target/mysql-crud-*.jar mysql-crud.jar
ENTRYPOINT ["java", "-jar", "mysql-crud.jar"]
## docker-compose.yml
version: '3.9'
services:
dockersql:
image: mysql:latest
restart: always
container_name: dockersql
ports:
- "3306:3306"
env_file: .env
environment:
- MYSQL_DATABASE=$MYSQL_DATABASE
- MYSQL_USER=$MYSQL_USER
- MYSQL_PASSWORD=$MYSQL_PASSWORD
- MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
networks:
- crud-network
mycrud:
depends_on:
- dockersql
restart: always
container_name: mycrud
env_file: .env
environment:
- MYSQL_HOST=dockersql:3306
- MYSQL_DATABASE=$MYSQL_DATABASE
- MYSQL_USER=$MYSQL_USER
- MYSQL_PASSWORD=$MYSQL_PASSWORD
- MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
build: .
networks:
- crud-network
networks:
crud-network:
driver: bridge
# .env file
MYSQL_DATABASE=test-db
MYSQL_USER=admin
MYSQL_PASSWORD=nimda
MYSQL_ROOT_PASSWORD=nimda
Can anyone help me?
Even better add a health check for MySQL and make it a condition for spring boot to start
dockersql:
healthcheck:
test: [ "CMD-SHELL", 'mysql --user=${MYSQL_USER} --database=${MYSQL_DATABASE} --password=${MYSQL_PASSWORD} --execute="SELECT count(table_name) > 0 FROM information_schema.tables;"' ]
mycrud:
depends_on:
dockersql:
condition: service_healthy
The --execute can also be modified to include application-specific healthcheck. for example, checking on a specific table that it exists.
I found out that before MySQL is completely up and running, my spring boot tries to connect MySQL and that is causing the error.
After adding
mycrud:
depends_on:
- dockersql
container_name: mycrud
restart: on-failure
It resolves my issue.

Docker Compose Error: services Additional property ​* is not allowed

Question
Is the following output an error?
Target
I want to run frontend, backend and a database container through Docker.
I want to hot reload my docker-compose builds on code changes.
Context
If I run this on PowerShell: docker-compose build; docker-compose up -d, I ran into this:
services Additional property ​mongodb is not allowed
services Additional property ​mongodb is not allowed
docker-compose.yml:
version: '3.8'
services:
api:
build: ./api
container_name: api
ports:
- 4080:4080
networks:
- network-backend
- network-frontend
depends_on:
- '​mongodb'
volumes:
- .:/code
​mongodb:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
ports:
- 27017:27017
networks:
- network-backend
volumes:
- db-data:/mongo-data
volumes:
db-data:
networks:
network-backend:
network-frontend:
I thought this is regarded to this issue.
OK found the answer. There are a weird chars in the config file. VS Code and Notebook don't showed me the chars. After testing a couple online YAML validators, I detected the issue.
Youtube Video of the Error

How to configure docker-compose.yml to use passbolt with docker-compose?

I use docker with WSL2 on a Debian VM and i'm trying to install passbolt.
I follow the steps on this guide : https://help.passbolt.com/hosting/install/ce/docker.html.
When i run docker-compose up, it's working and i can reach the database with telnet but it's impossible to reach the instance of passbolt with telnet and with my browser.
It's strange because the two containers: mariadb and passbolt are running.
This is my docker-compose.yml:
version: '3.4'
services:
db:
image: mariadb:10.3
env_file:
- env/mysql.env
volumes:
- database_volume:/var/lib/mysql
ports:
- "127.0.0.1:3306:3306"
passbolt:
image: passbolt/passbolt:latest-ce
#Alternatively you can use rootless:
#image: passbolt/passbolt:latest-ce-non-root
tty: true
container_name: passbolt
restart: always
depends_on:
- db
env_file:
- env/passbolt.env
volumes:
- gpg_volume:/etc/passbolt/gpg
- images_volume:/usr/share/php/passbolt/webroot/img/public
command: ["/usr/bin/wait-for.sh", "-t", "0", "db:3306", "--", "/docker-entrypoint.sh"]
ports:
- 80:80
- 443:443
#Alternatively for non-root images:
# - 80:8080
# - 443:4433
volumes:
database_volume:
gpg_volume:
images_volume:
If anybody can help me, thanks!
Your docker-compose file looks quite ordinary and I don't see any issues.
Can you please attach your passbolt.env and mysql.env (remove any important information ofcourse).
Also, the passbolt.conf (VirtualHost) might be useful.
Make sure that the DNS A record is valid and that you have no firewall blocks.
Error logs will be appreciated aswell.

Docker Build Stuck on MariaDB Installation

I am trying to build a set of Docker images that includes an installation of Magento 2 and MariaDB. In rare cases it succeeds (although this could be due to small changes in the app), but in most cases it is stuck on the following:
magento2-db | Version: '10.3.11-MariaDB-1:10.3.11+maria~bionic' socket: '/var/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
I see that someone else had this issue, but the cause was actual RUN commands for MariaDB installation, which I don't directly call. There doesn't seem to be anything in the log to indicate an error either.
The last lines in the log are:
[16:49:18.424][Moby ][Info ] [25693.252573] br-83922f7da47b: port 2(vethac51834) entered blocking state
[16:49:18.453][Moby ][Info ] [25693.290035] br-83922f7da47b: port 2(vethac51834) entered forwarding state
[16:49:18.637][ApiProxy ][Info ] time="2018-11-28T16:49:18+02:00" msg="proxy << POST /v1.25/containers/67175238f0e7a75ef527dbebbb1f5d992f1d01ee166643186dc5f727638aa66b/start (1.0560013s)\n"
[16:49:18.645][ApiProxy ][Info ] time="2018-11-28T16:49:18+02:00" msg="proxy >> GET /v1.25/events?filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dmagento2%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D\n"
It seems to actually finish executing all steps in the Dockerfile, but I suspect there might be a problem in my docker-compose file, which looks like this:
version: '3.0'
services:
app:
build:
context: .
dockerfile: .docker/Dockerfile
container_name: 'magento-2.2.6'
ports:
- "80:80"
volumes:
- magento2-test-env:/var/www/html/magento2 # will be mounted on /var/www/html
links:
- magento2-db
env_file:
- .docker/env
depends_on:
- magento2-db
magento2-db:
container_name: 'magento2-db'
image: mariadb:latest
ports:
- "9809:3306"
volumes:
- magento2-db-data:/var/lib/mysql/data
env_file:
- .docker/env
volumes:
magento2-db-data:
magento2-test-env:
external: true
Is there anything obviously wrong with my setup, and is there a good way to troubleshoot this, maybe look for something specific in the log?
maybe the way you're building your composer what's the problem.
Try use this one:
version: '3.0'
services:
app:
build:
context: .
dockerfile: .docker/Dockerfile
container_name: 'magento-2.2.6'
ports:
- "80:80"
volumes:
- magento2-test-env:/var/www/html/magento2 # will be mounted on /var/www/html
links:
- magento2-db
env_file:
- .docker/env
depends_on:
- db
db:
container_name: 'magento2-db'
image: mariadb:latest
ports:
- "9809:3306"
volumes:
- /var/lib/mysql/data
env_file:
- .docker/env
volumes:
magento2-db-data:
magento2-test-env:
external: true
Avoid to use services names like 'blabla-something' if you need put a name use as container_name it'll be enough, and the db, links always should links in the services itself no in the containers name.
I hope this could help you.
Try setting -e MYSQL_INITDB_SKIP_TZINFO=1, refer to this issue.
e.g.
docker run -it --rm -e MYSQL_INITDB_SKIP_TZINFO=1 ... mariadb:10.4.8

Docker compose up does not restart on reboot

I have successfully created docker containers and they work when loaded using:
sudo docker-compose up -d
The yml is as follows:
services:
nginx:
build: ./nginx
restart: always
ports:
- "80:80"
volumes:
- ./static:/static
links:
- node:node
node:
build: ./node
restart: always
ports:
- "8080:8080"
volumes:
- ./node:/usr/src/app
- /usr/src/app/node_modules
Am I supposed to create a service for this. Reading the documentation I thought that the containers would reload in restart was set to always.
FYI: the yml is inside a projects directory on the home of the base user: ubuntu.
I tried checking for solutions in stack but could not find anything appropriate. Thanks.

Resources